maven mvn编译错误:错误阅读jar错误在打开zip文件

7qhs6swi  于 2023-03-01  发布在  Maven
关注(0)|答案(2)|浏览(219)

我有一个具有这些性质的x-模:
模块名称:x数据模型
这是pom.xml的一部分

<groupId>com.x.datamodel</groupId>
<artifactId>x</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

我已经安装项目在一个本地存储库与此命令行:

mvn install:install-file -Dfile=/Users/me/Documents/Projects/x-datamodel/target/classes/x-datamodel.jar -DgroupId=com.x.datamodel -DgeneratePom=true -DlocalRepositoryPath=/Users/me/Documents/Projects/me-repository  -DcreateChecksum=true -DartifactId=x -Dversion={1.0} -Dpackaging=jar

并将该项目添加到bitbucket中。
我尝试将模块x集成到另一个项目y中。
这里是y的pom.xml的一部分

<dependency>
    <groupId>com.x.datamodel</groupId>
    <artifactId>x</artifactId>
    <version>${x.version}</version>
</dependency>

<repositories>
    <repository>
        <id>me-repository</id>
        <url>https://bitbucket.org/me/me-repository/src/master</url>
    </repository>
</repositories>

我可以在项目y中导入模块x的一些类,但是当我构建y项目时,我得到这个错误:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[18,12] cannot find symbol
  symbol:   class User
  location: class com.y.server.serviceImpl.UserServiceImpl
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/security/CustomUserDetailsService.java:[3,32] package com.x.datamodel.model does not exist
[INFO] 16 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:56 min
[INFO] Finished at: 2016-12-28T15:51:05+01:00
[INFO] Final Memory: 29M/209M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project y: Compilation failure: Compilation failure:
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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

安装后,我有库到这个路径:

.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar

原因:

.m2/repository/com/x-datamodel/x/1.0/x-1.0.jar
qij5mzcb

qij5mzcb1#

我倾向于认为该文件已损坏。请尝试删除它,然后重新下载。

xurqigkl

xurqigkl2#

尝试删除以下行

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

其中:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
</plugin>

相关问题