spring-boot:application.properti
2018-12-25 本文已影响0人
BenjaminCool
application-properties:是spring-boot默认加载的,是个入口:所有需要配置的在这个文件中指定:
- profiles
spring.profiles.active=dev,hsqldb
For example, when an application with the following properties is run by using the switch, --spring.profiles.active=prod, the proddb and prodmq profiles are also activated:
my.property: fromyamlfile
spring.profiles: prod
spring.profiles.include:
- proddb
- prodmq
- 要想替换:application-properties:可以在命令行中指定:
$ java -jar myproject.jar --spring.config.name=myproject
$ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
- 加载其他的属性文件:
可以用: spring.profiles.include, 加载其他的额外的属性文件;
也可用@PropertySource("application-demo.properties")