We can have some properties defined inside application.properties or application.yml file.
application.properties:
app.name=Frank
app.greeting=Hello
We can get those value by @Value:
@Configuration @PropertySource("classpath:application.properties") public class ApplicationConfig { @Value("${app.greeting}") private String greeting; @Value("${app.name}") private String name; ... }
@PropertySource is used to defined where to looking for application.properties file. Normally it should be located in 'resources' folder.
'classpath': points to 'resources' folder.
Environment variable:
we can also override those properties by environment varialbe: