I have 2 modules in my project app & starter. Starter contains @Configuration
and tells how a bean of ServiceFoo
should be created.
@Configuration
@EnableConfigurationProperties(FooServiceConfiguration.class)
public class StarterFoo {
@Bean
public ServiceFoo defaultBean(FooServiceConfiguration conf){
new ServiceFooImpl(conf.getName(), conf.getNumber());
}
}
I have another configuration class in my starter.
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("Foo")
public class FooServiceConfiguration {
private String name;
private int number;
// + accessors
}
in my starter I have application.yml
which has
Foo:
name: DefaultName
number: 101
starter is configured to be auto-configured
META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=StarterFoo
I want to have opinion on my config about number and user will never worry and override that number. I want users to override name in my config.
As soon as I create application.yml in app (blank file) the effect of starter's config (from application.yml from starter) goes away.
How can I partially override this config from app which is defined in starter ?