I have beans:
@Configuration
@PropertySource("classpath:bean.properties")
class Config{
@Bean
@ConditionalOnProperty(name = "property.validation")
@Order(1)
public BeanInterface beanInterface(@Value("${property.validation}" String valid) {
return new MyBean(valid);
}
@Bean("beanInterface")
@ConditionalOnMissingBean(MyBean.class)
@Order(2)
public BeanInterface beanInterface() {
return new MyBean2();
}
}
Now, if "property.validation" exists inside "bean.properties" file, MyBean()
is created, if the property does not exists MyBean2()
is created, however, if bean.properties
file does not exists neither is created. And i want to create MyBean2
if the file does not exists.
Can i achieve something like this with spring?