【发布时间】:2015-03-21 07:33:29
【问题描述】:
我有几个与我在项目中使用的一些内部项目相关的 jar。这些正在使用 maven install 命令安装在本地 maven 存储库中,因为它们在任何存储库中都不可用。
但是,当我尝试构建应用程序时,它失败并出现错误:
error: error reading D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-web-0.1.6.jar
error in opening zip file
错误跟踪:
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
error: error reading D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-
web-0.1.6.jar; error in opening zip file
error: error reading D:\proj\.m2\repository\com\microsoft\sqljdbc\2005\sqljdbc
-2005.jar; error in opening zip file
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: Compilation failure
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation fail
ure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:516)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
... 17 more
https://gist.github.com/avchavan/01eb6e46e00dc86708d0
依赖片段:
<dependency>
<groupId>com.affecto</groupId>
<artifactId>bolib-web</artifactId>
<version>0.1.6</version>
</dependency>
我已尝试删除整个 .m2,但还是一样。 jar 文件正确打开,我可以看到它的内容。 所以这对我来说似乎不是问题。 此外,jar 内没有 html 页面(仅限 java 文件)。 当我打开罐子时,我可以看到罐子是使用 maven 制作的,因为它带有一个 pom 文件。 这可能是什么问题?
谢谢。
【问题讨论】:
-
为什么将文件直接放在“存储库”目录中。通常它被放置在 .m2\repository\com\google\code\gson\gson\2.3\gson-2.3.jar 之类的地方
-
maven 路径看起来不正确,因为通常有组织/版本/工件路径。尝试运行
mvn -X。还有你是如何安装 jar 的。你跑mvn install了吗?还是您只是复制了 jar(这不起作用)。 -
@StanislavL 它已经在 .m2 文件夹中(D:\proj\.m2\repository\com\affecto\bolib-web\0.1.6\bolib-web-0.1.6.jar)。
-
@AdamGent 是的,使用 mvn install (mvn install:install-file -DgroupId=com.affecto -DartifactId=bolib-web -Dversion=0.1.6 -Dpackaging=jar -Dfile=D:/ BOProj/JavaLibFiles/bolib-web-0.1.6.jar)。编辑了问题中的路径。