【问题标题】:Error in opening manually installed jars maven打开手动安装的jar maven时出错
【发布时间】: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)。编辑了问题中的路径。

标签: java maven jar maven-2


【解决方案1】:

在查看了您的 Maven 输出并没有发现太多错误之后,我真的只能得出结论,这是 Windows 文件权限问题或 Windows 文件锁定问题。

对于 Windows 文件权限:

我建议您尝试以“管理员”身份运行所有内容,或者递归地删除/添加权限到.m2,以便所有用户都可以读写,看看是否是问题所在。 (我相信我在 Windows 上已经有一段时间了,但是你右键单击命令图标并选择以管理员身份运行)。

对于 Windows 文件锁定问题:

您可能有一个仍在写入/读取的陈旧进程,该进程已锁定文件。我注意到这实际上在 Windows 上经常发生。最简单的解决方案是重新启动,但有一些程序可以查找和删除文件锁定。

【讨论】:

  • 我尝试以管理员权限运行,但仍然遇到同样的错误。重启机器,还是一样的错误。
猜你喜欢
  • 1970-01-01
  • 2018-08-02
  • 2020-04-27
  • 2016-08-21
  • 1970-01-01
  • 1970-01-01
  • 2010-12-24
  • 2015-02-17
  • 2019-07-30
相关资源
最近更新 更多