Nik*_*hil 6 java jar noclassdeffounderror maven
我想创建一个 jar(无主类),稍后在 apache pig 中用作 UDF。
当我使用 maven 创建 jar 时,依赖的 jar 不包含在输出 jar 中。
pom 文件看起来像这样
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>AppName</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>xzloader-java-pig-udf</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.pig</groupId>
<artifactId>pig</artifactId>
<classifier>h2</classifier>
<version>0.13.0</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
但结果罐子总是抛出
NoClassDefFoundException
与 apache pig 一起运行时
这是我的 pom.xml 的摘录,它构建了一个具有依赖项的 jar:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>attached</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我看到的区别是目标:你使用single,我使用attached。
| 归档时间: |
|
| 查看次数: |
10155 次 |
| 最近记录: |