阅读目录(Content)
修改pom.xml文件
回到顶部(go to top)
修改pom.xml文件
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<!--打包时排除掉资源文件-->
<excludes>
<exclude>**/**</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--拷贝第三方依赖文件到指定目录-->
<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>
<!--target/lib是依赖jar包的输出目录,根据自己喜好配置-->
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
在target中把lib目录和jar文件再加了项目中的resource目录一起发布,启动命令是: java -jar -Dloader.path=.,resources,lib (可执行的jar包名称).jar
win10 用cmd 不要用powershell