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
194 views
in Technique[技术] by (71.8m points)

java - Spring Boot: how to use multiple yml files

In Spring Boot, I know that I can replace application.properties with application.yml and use the YAML format. However, my application.yml is getting crowded so I need to split it up a bit. How can I do that? I would like to do something like this:

...
@Configuration
@EnableAutoConfiguration
@EnableWebMvc
@EnableScheduling
@PropertySource({"classpath:application.yml", "classpath:scheduling.yml"})
public class ApplicationConfig {
...
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)
  1. remove @PropertySource annotation, you not need it
  2. rename your scheduling.yml into src/main/resources/application-scheduling.yml
  3. add in src/main/resources/application.yml file next line:

    spring.profiles.include: 'scheduling'


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

...