Spring @Value property for custom class
It's possible but reading Spring documentation. You could see this example: Example usage
@Configuration
@PropertySource("classpath:/com/myco/app.properties")
public class AppConfig {
@Autowired
Environment env;
@Bean
public TestBean testBean() {
TestBean testBean = new TestBean();
testBean.setName(env.getProperty("testbean.name"));
return testBean;
}
}
See details here
You have to create a class extending PropertyEditorSupport
.
public class CustomerEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) {
Customer c = new Customer();
// Parse text and set customer fields...
setValue(c);
}
}