![](/img/trans.png)
[英]An exception occured while executing the Java class. java.lang.InterruptedException
[英]Exception while executing java class
我執行了這個命令
mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=crawler.Crawler
並發現了這個
執行Java類時發生異常。 組織/阿帕奇/ log4j的/記錄器
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" si:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
<repository>
<id>twitter4j.org</id>
<name>twitter4j.org Repository</name>
<url>http://twitter4j.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
第二部分
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
錯誤
java.lang.NoClassDefFoundError:org / apache / log4j / Logger
您需要添加對log4j的依賴
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
到pom.xml文件(依賴於junit之后)。
您可以在Maven倉庫中了解有關此依賴項的信息: http : //mvnrepository.com/artifact/log4j/log4j/1.2.17
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.