3个配置文件:
核心配置文件:application.properties
开发环境用的配置文件:application-dev.properties
生产环境用的配置文件:application-pro.properties
这样就可以通过application.properties里的spring.profiles.active 灵活地来切换使用哪个环境了
application.properties
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
spring.profiles.active=pro
application-dev.properties
server.port=8080
server.context-path=/test
部署时指定配置
java -jar target/springboot-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
网友评论