我想将我的项目打包在一个可执行的JAR中进行分发.
如何将所有依赖JAR的Maven项目打包到我的输出JAR中?
我正在通过Maven与Apache Spark一起工作,并且尝试通过包含第3方jar并尝试利用其中的某些方法来修改源。
使用编译Spark项目时出现以下错误
mvn -Dhadoop.version=2.2.0 -Dscala-2.11 -DskipTests clean package
Run Code Online (Sandbox Code Playgroud)
not found: object edu
[ERROR] import edu.xxx.cs.aggr._
Run Code Online (Sandbox Code Playgroud)
我修改ResultTask.scala为包含导入语句。因此,maven无法找到我要使用的jar并将其与项目链接。
我已经将依赖项添加到pom.xml文件中,如下所示:
<dependency>
<groupId>edu.xxx.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
<scope>system</scope>
<systemPath>${basedir}/aggr.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我尝试链接的jar文件与spark pom.xml文件位于同一目录中。我将此依赖项添加到pom.xml。我将其插入pom.xml文件中的2个现有依赖关系之间。我不确定出什么问题,但是我现在想立即关联该jar,以便可以使用其中的方法。我也不确定我是否应该使用特定于groupId,artifactId和版本的任何东西。edu.xxx.cs.aggr是包含其他源文件和软件包的根软件包。我将不胜感激任何帮助。
更新
我用了
mvn install:install-file -Dfile=<path-to-file> -DgroupId=edu.xxx.cs -DartifactId=aggr -Dversion=0.99 -Dpackaging=jar to install the jar to the .m2 repo. I checked the repo to see if it was installed, and it was.
Run Code Online (Sandbox Code Playgroud)
我将pom.xml中的依赖项更改为
<dependency>
<groupId>edu.purdue.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我仍然遇到相同的错误。