springboot 打包不同环境映射参数,添加profiles区别各个环境进行打包
1.创建不同环境下的目录文件
2.设置key值对应关系
3.添加profiles配置
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/resources/config/dev/base.properties</filter>
<filter>src/main/resources/config/dev/config.properties</filter>
<filter>src/main/resources/config/dev/java_opts.properties</filter>
</filters>
</build>
</profile>
</profiles>
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**.*</include> <include>**/*.*</include><!-- i18n能读取到 --> <include>**/*/*.*</include> </includes> <filtering>true</filtering> 这个参数配置决定是否会替换打包配置 </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <mainClass>com.polymer.app.StartApplication</mainClass> <layout>ZIP</layout> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> <finalName>boot-polymer</finalName> </build>
4.打包指定profile
5.替换成功