美文网首页
spring boot 配置文件切换

spring boot 配置文件切换

作者: cccccttttyyy | 来源:发表于2018-08-28 09:05 被阅读0次

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

相关文章

网友评论

      本文标题:spring boot 配置文件切换

      本文链接:https://www.haomeiwen.com/subject/glqbiftx.html