您好,登錄后才能下訂單哦!
springboot的打包方式有很多種。可以打war包,可以打jar包,可以使用jekins進行打包部署的。不推薦用war包,SpringBoot適合前后端分離,打成jar進行部署更加方便快捷。
banner.txt內容
=======================
No BUG
=======================
這樣就替換了原先SpringBoot的啟動樣式。
<!-- 項目構建 -->
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- SpringBoot插件:JDK編譯插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- SpringBoot插件:打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 跳過單元測試 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
1)application.yml配置
server:
port: 8017
spring:
application:
name: node17-boot-package
profiles:
active: dev
2)application-dev.yml配置
project:
sign: develop
3)application-pro.yml配置
project:
sign: product
package com.boot.pack.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PackController {
@Value("${project.sign}")
private String sign ;
@RequestMapping("/getSign")
public String getSign (){
return sign ;
}
}
mvn clean install -pl node17-boot-package -am -Dmaven.test.skip=true
生成Jar包:node17-boot-package.jar
運行dev環境
java -jar node17-boot-package.jar --spring.profiles.active=dev
運行pro環境
java -jar node17-boot-package.jar --spring.profiles.active=pro
http://localhost:8017/getSign
dev環境打印:develop
pro環境打印:product
GitHub地址:知了一笑
https://github.com/cicadasmile/spring-boot-base
碼云地址:知了一笑
https://gitee.com/cicadasmile/spring-boot-base
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。