Spring @PropertySource example
In Spring, you can use @PropertySource annotation to externalize your configuration to a properties file 1. @PropertySource and @Value A classic example, read a properties file and display with ${} . config.properties mongodb.url = 1.2.3.4 mongodb.db = hello Copy AppConfigMongoDB package com . app .example. config ; import org . springframework . beans . factory . annotation . Value ; import org . springframework . context . annotation . Bean ; import org . springframework . context . annotation . ComponentScan ; import org . springframework . context . annotation . Configuration ; import org . springframework . context . annotation . PropertySource ; import org . springframework . context . support . PropertySourcesPlaceholderConfigurer ; //... @Configuration @ComponentScan ( basePackages = { "com.app.*" } ) @PropertySource ( "classpath:config.properties" ) public class AppConfigMongoDB { //1.2.3.4 @Value ( "${...