Springboot 前后端分离打包部署
1. 将前端工程目录拷贝到 Springboot 项目的 resources/static 目录下
2. pom.xml 打包配置如下
<build>
<plugins>
<!-- springboot 打包插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 打包时跳过单元测试插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<!--打包剔除application.properties配置文件-->
<exclude>**/*.properties</exclude>
</excludes>
<includes>
<!--打包添加前端静态文件-->
<include>src/resources/static</include>
</includes>
</resource>
</resources>
</build>
3. 执行 jar 打包命令
clean
install
4. 运行 jar 包命令
Dspring.config.location:指定外部 application.properties 配置文件路径
> java -jar -Dspring.config.location=C:\Users\application.properties C:\backend-0.0.1-SNAPSHOT.jar