【发布时间】:2018-01-25 03:44:46
【问题描述】:
我的系统中有一个 jar,我想使用 maven 将它打包到 jar 应用程序中,我的依赖项和插件如下:
<dependency>
<groupId>org.wltea</groupId>
<artifactId>IKAnalyzer</artifactId>
<version>3.2.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/BOOT-INF/lib/IKAnalyzer3.2.3Stable.jar</systemPath>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>gpdi.MyApp</mainClass>
</configuration>
</execution>
</executions>
</plugin>
我也尝试过maven-dependency-plugin,但打包 jar 文件时不起作用。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/BOOT-INF/lib</outputDirectory>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
【问题讨论】:
-
你看到什么样的行为?您的项目是否继承自 Spring Boot? docs.spring.io/spring-boot/docs/current/reference/html/…
-
@yngwietiger 是的,我使用的是spring-boot,可以在IDEA中运行主类,但是我不知道如何打包可以在服务器上运行的jar文件
标签: java maven spring-boot jar