<> hit jar package

springboot Project packaging by environment
hit jar package

If it is a multi module project , For example, I have the following directory structure

among api The project configuration is as follows

1 First configure in the top-level project pom Add the following configuration to the file
<!-- Define the corresponding profileActive Variable value --> <profiles> <profile> <id>dev</id>
<properties> <profileActive>dev</profileActive> </properties> <activation>
<!-- Specify default activation --> <activeByDefault>true</activeByDefault> </activation> </profile>
<profile> <id>prd</id> <properties> <profileActive>prd</profileActive>
</properties> </profile> </profiles>
2 And then api engineering pom Add the following configuration to the file
<!--maven pack --> <build> <finalName>ftyj</finalName> <resources> <resource>
<directory>src/main/resources</directory> <filtering>true</filtering>
<excludes> <exclude>application-prd.properties</exclude>
<exclude>application.properties</exclude> </excludes> </resource>
<!-- Resources that need to be added dynamically --> <resource> <directory>src/main/resources</directory>
<filtering>true</filtering> <includes> <!-- Read the environment specified in the packaging command -->
<include>application.properties</include> </includes> </resource> </resources>
3 stay application.properties Add the following reference variable configuration to

4 Then start using maven Command packaging , If is idea Environmental Science , Right click item selection open in terminal

Open console

Enter the following packaging command , Clean up compilation package prd development environment , It just means application-prd.properties and application.properties Drive in jar package

mvn clean compile package -Dmaven.test.skip=true -Pprd
6 View compilation results

Open with decompression software jar package

Replace packing dev Environmental Science
mvn clean compile package -Dmaven.test.skip=true -Pdev

You can see that the bag has been changed to dev And general profile

7 If it is a single project instance, the top-level project will be directly pom Configuration and api The environmental configuration summary of the engineering team can be transferred to a single project

©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?