如何创建具有特定依赖项的胖jar。我有Spark项目,需要2个外部jar,我想添加到应用程序jar。当我创建可执行jar时,jar中不包含依赖项,当我创建fatjar时,所有依赖项都被添加,包括spark等。。我只想把那两个jar放进我的jar里。下面是我使用maven汇编插件创建的pom文件。
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<!-- Below dependencies need to be added in Application jar -->
<dependency>
<groupId>netacuity</groupId>
<artifactId>common-netacuity-db</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>netacuity</groupId>
<artifactId>common</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>com....App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
1条答案
按热度按时间ff29svar1#
你可以用
scope
为了这个。默认情况下scope
是compile
所以当你打包的时候,所有的jar都会包括在内。要包含一个jar,您可以
scope
作为compile
并保持default
```netacuity
common-netacuity-db
3.1.2
compile