Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

spring boot - Not clear why my second application.yml is not loaded

I try to start a simple Spring Boot application (APP) which use a library dependency (LIB).

LIB provide commons configuration with application.yml in root classpath. APP provide specific configuration through its own application.yml also in root classpath.

When the APP started, Spring Boot complains that it can't find some properties (those from LIB). If I move the LIB application.yml under config/ in class path, everything goes fine.

Reading the documentation (https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-files), it is not clear why every classpath:/application.yml aren't loaded. Is it expected behavior ?

question from:https://stackoverflow.com/questions/65625859/not-clear-why-my-second-application-yml-is-not-loaded

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, this is the expected behaviour. When loading from the classpath, the first application.yml file that is found will win and any other files with the same name on the classpath will be ignored.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...