我的Maven项目一切都很好,直到添加webutilities库。
我添加了依赖项和存储库:
<dependency>
<groupId>com.google.javascript</groupId>
<artifactId>closure-compiler</artifactId>
<version>v20140407</version>
<type>jar</type>
</dependency>
..........
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
正如在库的页面https://maven-repository.com/artifact/com.googlecode.webutilities/webutilities/0.0.7中所说的那样,并声明了servlet:
<servlet>
<servlet-name>JSCSSMergeServlet</servlet-name>
<servlet-class>com.googlecode.webutilities.servlets.JSCSSMergeServlet</servlet-class>
<!-- This init param is optional and default value is minutes for 7 days in future. -->
<init-param>
<param-name>expiresMinutes</param-name>
<param-value>14400</param-value> <!-- 10 days -->
</init-param>
<!-- This init param is also optional and default value is 'public'.-->
<init-param>
<param-name>cacheControl</param-name>
<param-value>public</param-value>
</init-param>
</servlet>
.......
<servlet-mapping>
<servlet-name>JSCSSMergeServlet</servlet-name>
<url-pattern>*.js</url-pattern>
<url-pattern>*.json</url-pattern>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
如页面所示:https://code.google.com/p/webutilities/wiki/JSCSSMergeServlet
当我尝试使用mvn package -o -X
打包时,它会给我一个错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project lrms-web-utm: Compilation failure: Compilation failure:
[ERROR] error: error reading /home/fatih/.m2/repository/com/googlecode/webutilities/webutilities/0.0.7/webutilities-0.0.7.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/yahoo/platform/yui/yuicompressor/2.4.7/yuicompressor-2.4.7.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/rhino/js/1.6R7/js-1.6R7.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/google/javascript/closure-compiler/v20140407/closure-compiler-v20140407.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/google/javascript/closure-compiler-rhino/v20140407/closure-compiler-rhino-v20140407-shaded.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/google/javascript/closure-compiler-externs/v20140407/closure-compiler-externs-v20140407.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/args4j/args4j/2.0.26/args4j-2.0.26.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/org/json/json/20090211/json-20090211.jar; error in opening zip file
[ERROR] error: error reading /home/fatih/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar; error in opening zip file
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project lrms-web-utm: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
在我看来,一些更深层次的依赖导致了这个错误,但我无法弄明白。