简体   繁体   中英

Spring configuration class from a specific properties file

Suppose I have a @Configuration class or better yet a @ConfigurationProperties class.

I'd like the configuration to be loaded from a specific application-x.properties file.

How can I do that? (without defining a new Spring profile)

You have to use @PropertySources , ex: @PropertySource("classpath:foo.properties") .

Check this to have more insight and see the other options. https://www.baeldung.com/properties-with-spring

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM