<> 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-dev.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-${profileActive}.properties</include>
<include>application.properties</include> </includes> </resource> </resources>
</build>
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

5
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

Technology
©2019-2020 Toolsou All rights reserved,
Android 11 Official release !Map---Java judge Map Contains a keySpark SQL- programming Vue Transfer parameters and receiving of page Jump css Basics 2:flex Multi row layout with gaps ajax get Request Chinese parameter garbled solution mysql Modify primary key Python Multithreading programming ( One ):threading modular Thread The usage of class 【Python- data fetch 】 read txt Each line of file generates a list of data Maximum security risk of cloud computing : Unclear safety responsibility