在Netbeans java.lang.ClassNotFoundException中使用Maven运行项目时出现问题:

时间:2018-10-07 04:59:33

标签: java maven build pom.xml

我在尝试在Netbeans中运行项目时遇到问题,我也尝试通过CLI安装.jar,仍然出现此错误。

Netbeans中的输出: 清理并构建:

cd /home/danillo/Desktop/TCC/collector; JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 /home/danillo/netbeans-8.2/java/maven/bin/mvn clean install

--- maven-install-plugin:2.3.1:install (default-install) @ collector ---
Installing /home/danillo/Desktop/TCC/collector/target/collector-1.0-SNAPSHOT.jar to /home/danillo/.m2/repository/edu/utfpr/collector/1.0-SNAPSHOT/collector-1.0-SNAPSHOT.jar
Installing /home/danillo/Desktop/TCC/collector/pom.xml to /home/danillo/.m2/repository/edu/utfpr/collector/1.0-SNAPSHOT/collector-1.0-SNAPSHOT.pom 
------------------------------------------------------------------------
    BUILD SUCCESS
------------------------------------------------------------------------

运行:

Exception in thread "main" java.lang.NoClassDefFoundError: com/pragone/jphash/jpHash
at edu.utfpr.xbi.merger.image.PHashCompartor.compare(PHashCompartor.java:14)
at edu.utfpr.xbi.merger.BrowserMerger._merge(BrowserMerger.java:82)
at edu.utfpr.xbi.merger.BrowserMerger.merge(BrowserMerger.java:63)
at edu.utfpr.xbi.merger.Merger.main(Merger.java:55)
at CollectorPipeline.main(CollectorPipeline.java:22)
Caused by: java.lang.ClassNotFoundException: com.pragone.jphash.jpHash
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 6.520s
Finished at: Sun Oct 07 01:44:20 BRT 2018
Final Memory: 9M/97M

我检查所有类和.jar是否都在正确的位置,也许是错误的。

我的pom.xml:

<repositories>
  <repository>
      <id>dependencies</id>
      <url>file:///${project.basedir}/dependencies</url>
  </repository>

<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.7.1</version>
  </dependency>
  <dependency>
      <groupId>io.appium</groupId>
      <artifactId>java-client</artifactId>
      <version>4.1.2</version>
  </dependency>
  <dependency>
      <groupId>ru.yandex.qatools.ashot</groupId>
      <artifactId>ashot</artifactId>
      <version>1.5.5-SNAPSHOT</version>
  </dependency>
  <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>2.10.0</version>
  </dependency>
  <dependency>
      <groupId>nu.pattern</groupId>
      <artifactId>opencv</artifactId>
      <version>2.4.9-7</version>
  </dependency>
  <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.6</version>
  </dependency>
  <dependency>
      <groupId>com.pragone</groupId>
      <artifactId>jpHash</artifactId>
      <version>1.0-SNAPSHOT</version>
     <scope>system</scope>
     <systemPath>${project.basedir}/dependencies/jpHash-1.0-SNAPSHOT.jar</systemPath>
  </dependency>
  <dependency>
      <groupId>sun.jvm.hotspot</groupId>
      <artifactId>sa-jdi</artifactId>
      <version>1.0</version>
     <scope>system</scope>
     <systemPath>${project.basedir}/dependencies/sa-jdi.jar</systemPath>
  </dependency>
</dependencies>
</project>

我看到了很多话题,却无济于事,这真让我烦恼。

0 个答案:

没有答案