@PropertySource
represent add a property source file
for our configuration
that will determine where the properties will be read from.
@PropertySource("classpath:/mysql.properties")
public class MySQLAutoconfiguration {
//...
}
# @PropertySource use Java8 repeating annotations feature`, which means we can mark a class with it multiple times:
@Configuration
@PropertySource("classpath:/annotations.properties")
@PropertySource("classpath:/vehicle-factory.properties")
class VehicleFactoryConfig {}
# Use @PropertySources to specify multiple @PropertySource configurations
@Configuration
@PropertySources({
@PropertySource("classpath:/annotations.properties"),
@PropertySource("classpath:/vehicle-factory.properties")
})
class VehicleFactoryConfig {}