spingboot中的依赖:
<plugins>
<!-- 上线部署 JAR启动分离依赖lib和配置 -->
<!-- 打包jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- 不打包资源文件 -->
<excludes>
<exclude>*.**</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!-- MANIFEST.MF 中 Class-Path 加入前缀 -->
<classpathPrefix>lib/</classpathPrefix>
<!-- jar包不包含唯一版本标识 -->
<useUniqueVersions>false</useUniqueVersions>
<!-- 指定入口类 -->
<mainClass>com.kong.DemoKonApplication</mainClass>
</manifest>
<!-- 指定配置文件目录,这样jar运行时会去找到同目录下的config文件夹下查找 -->
<manifestEntries>
<Class-Path>config/</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${package.path}</outputDirectory>
</configuration>
</plugin>
<!-- 拷贝依赖 copy-dependencies -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory> ${package.path}/lib/ </outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- 拷贝资源文件 copy-resources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- 指定参与构建的resource -->
<includes>
<include>*.**</include>
</includes>
</resource>
</resources>
<outputDirectory>${package.path}/config</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
宝塔终端运行命令:
nohup java -Dloader.path=./lib/ -Dspring.config.location=./config/application.yml -jar NCP-1.0-SNAPSHOT.jar > app.log 2>&1 &
- 目录如下: