maven的pom.xml中增加如下插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>validate</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jspWeb</outputDirectory>
<includeGroupIds>cn.test</includeGroupIds>
<includeArtifactIds>test-webapp</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<jar update="true" file="${project.build.directory}/${project.build.finalName}.jar"
compress="false">
<zipfileset dir="${project.build.directory}/jspWeb" prefix="jspWeb" />
</jar>
</target>
</configuration>
</execution>
</executions>
</plugin>
本文介绍了如何配置Maven插件,以便在Spring Boot项目打包成可执行jar时,将依赖项复制并放入指定的目录中,确保运行时能正确加载。
1134

被折叠的 条评论
为什么被折叠?



