搞了一上午,以前项目中使用profile多环境配置彻底没问题,但新项目死活不行。最后分析发现是由于引入spring-boot致使没法替换变量,而后又继续研究缘由。spring
spring-boot引用方式官方推荐是使用:app
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.6.RELEASE</version> </parent>
而后去看了一下对应的pom.xml文件,发现spring-boot为了保护application.yml和application.properties,修改了默认的占位符${...}为@...@,而后发现resources插件有一个配置项:maven
<useDefaultDelimiters>true</useDefaultDelimiters>
会使用默认的占位符,增长此配置项后就没问题了。spring-boot
resource插件完整的配置:.net
<plugin> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>utf-8</encoding> <useDefaultDelimiters>true</useDefaultDelimiters> </configuration> </plugin>
这个问题提及来就几句话,但profile多环境配置没有生效的时候真是一头雾水。插件