大家好,又见面了,我是你们的朋友全栈君。
1 在pom.xml中 <!–<filtering>true</filtering>–> 被注释掉
打包时能替换文件名,但是不能替换文件里面的标识符,启动项目时报错。
2 在pom.xml中 <filtering>true</filtering>
打包时能替换文件名,也能替换文件里面的标识符:启动时正常
——————————————————————————
1 在pom.xml中 <!–<filtering>true</filtering>–> 被注释掉
代码语言:javascript复制 <profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profilesActive>dev</profilesActive>
<activated_yml>dev</activated_yml>
</properties>
<build>
<resources>
<resource>
<!--<filtering>true</filtering>-->
<directory>src/main/resources</directory>
<includes>
<include>application.yml</include>
<include>application-${activated_yml}.yml</include>
<include>logback-dev.xml</include>
<include>spring-mvc.xml</include>
<include>spring-task.xml</include>
<include>mybatis/mapper/*.xml</include>
<include>mybatis/mybatis-config.xml</include>
</includes>
</resource>
</resources>
</build>
</profile>
打包时能替换文件名,但是不能替换文件里面的标识符:
启动项目时报错:
14:37:32.598 [main] ERROR org.springframework.boot.SpringApplication – Application run failed java.lang.IllegalStateException: Failed to load property source from location ‘classpath:/application.yml’
2 在pom.xml中 <filtering>true</filtering>
代码语言:javascript复制 <profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profilesActive>dev</profilesActive>
<activated_yml>dev</activated_yml>
</properties>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application.yml</include>
<include>application-${activated_yml}.yml</include>
<include>logback-dev.xml</include>
<include>spring-mvc.xml</include>
<include>spring-task.xml</include>
<include>mybatis/mapper/*.xml</include>
<include>mybatis/mybatis-config.xml</include>
</includes>
</resource>
</resources>
</build>
</profile>
打包时能替换文件名,也能替换文件里面的标识符:启动时正常
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/226884.html原文链接:https://javaforall.cn