spring-boot分环境打包为jar包
1.pom配置
<!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id>dev</id> <properties> <profiles.active>dev</profiles.active> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <!-- 测试环境配置 --> <profile> <id>test</id> <properties> <profiles.active>test</profiles.active> </properties> </profile> <!-- 正式环境 --> <profile> <id>online</id> <properties> <profiles.active>online</profiles.active> </properties> </profile> </profiles> <!-- 多环境打包 end --> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.class</include> <include>**/*.xml</include> <include>**/*.properties</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>*.xml</include> <include>*.properties</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources/conf/${profiles.active}</directory> </resource> </resources> </build>
2.打包命令
mvn clean package -Dmaven.test.skip=true -Ptest
3.启动命令
nohup java -jar demo.jar > /dev/null 2>&1 &