java.lang.NoClassDefFoundError: org/apache/maven/shared/io/location/LocatorStrategy

昨天晚上在用maven编译项目的时候,使用maven-assembly-plugin时,被卡在这个plugin上,其他都可以,正常的jar可以生成,但就是这个fat jar生成不了。

error如下:

[WARNING] Error injecting: org.apache.maven.plugin.assembly.mojos.AttachedAssemblyMojo
java.lang.NoClassDefFoundError: org/apache/maven/shared/io/location/LocatorStrategy
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
	at java.lang.Class.getDeclaredConstructors(Class.java:1901)

看来maven-assembly-plugin缺少依赖,但我换了好几个assembly的版本,还是不行。哎,最后没办法了,去.m2 repository里看看吧,哦,原来真的又maven-shared-io这个plugin,于是直接删除了该目录,然后再运行mvn clean package的时候:

[INFO] --- maven-assembly-plugin:2.5.3:single (make-assembly) @ go2maplog ---
[WARNING] The POM for org.apache.maven:maven-project:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.0/maven-shared-io-1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.0/maven-shared-io-1.0.pom (3 KB at 3.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.pom (4 KB at 10.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar (39 KB at 66.6 KB/sec)
[WARNING] Invalid POM for org.mockito:mockito-all:jar:1.8.5, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Building jar: 

于是,上面NoClassDefFoundError就不见了,jar-with-dependencies也自动生成了。

你可能感兴趣的:(maven)