我正在尝试创建jinjava应用程序: 的src /主/ JAVA / COM /公司/ Main.java
package com.company;
import com.hubspot.jinjava.Jinjava;
public class Main {
public static void main(String[] args) {
Jinjava jinjava = new Jinjava();
}
}
和pom.xml的一部分(感谢sof,我不能完全发布):
<repositories>
<repository>
<id>osssonatype</id>
<name>OSS Sonatype</name>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.hubspot.jinjava</groupId>
<artifactId>jinjava</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.company.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>jj4</finalName>
</build>
</project>
但是在“mvn clean install”和“java -jar target / jj4.jar”之后我得到了:
Exception in thread "main" java.lang.NoClassDefFoundError: com/hubspot/jinjava/Jinjava
at com.company.Main.main(Main.java:12)
Caused by: java.lang.ClassNotFoundException: com.hubspot.jinjava.Jinjava
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
怎么了?
答案 0 :(得分:0)
尝试这可以是任何帮助。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>class name along with package which has the main method</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>