maven profile true的作用
程序员文章站
2024-03-22 16:10:16
...
1 在pom.xml中 <!--<filtering>true</filtering>--> 被注释掉
打包时能替换文件名,但是不能替换文件里面的标识符,启动项目时报错。
2 在pom.xml中 <filtering>true</filtering>
打包时能替换文件名,也能替换文件里面的标识符:启动时正常
------------------------------------------------------------------------------
1 在pom.xml中 <!--<filtering>true</filtering>--> 被注释掉
<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>
<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>
打包时能替换文件名,也能替换文件里面的标识符:启动时正常
上一篇: HDFS oiv解析Fsimage OOM异常处理
下一篇: HDFS HA 架构分析