【问题标题】:Maven install is failing while trying to look for dependent project尝试查找依赖项目时 Maven 安装失败
【发布时间】:2020-06-25 19:28:03
【问题描述】:

我有一个依赖于 tos-base 的 order-core 项目。这是我的 pom.xml。我尝试了所有可能的堆栈溢出问题,但仍然出现错误。

我关注了

mvn 清洁 mvn 编译 mvn 编译依赖:树 mvn 干净安装

另外,我尝试使用 Xms 和 Xmx 设置 MAVEN_OPT。

另外,我再次创建了项目,但同样的错误。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.spectrum.sci</groupId>
    <artifactId>order-core</artifactId>
    <version>1.0</version>
    <name>order-core</name>
    <description>Order Core</description>

    <properties>
        <java.version>1.8</java.version>
        <cxf.version>3.2.0</cxf.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>

        <dependency>
            <groupId>com.spectrum.tos</groupId>
            <artifactId>tos-base</artifactId>
            <version>1.0</version>
         </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
            <version>${cxf.version}</version>
         </dependency>
         <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-service-description</artifactId>
            <version>${cxf.version}</version>
         </dependency>
         <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
         </dependency>


    </dependencies>

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

这是我得到的错误:

[INFO] Scanning for projects...
[INFO] 
[INFO] [1m--------------------< [0;36mcom.spectrum.sci:order-core[0;1m >---------------------[m
[INFO] [1mBuilding order-core 1.0[m
[INFO] [1m--------------------------------[ jar ]---------------------------------[m
[INFO] 
[INFO] [1m--- [0;32mmaven-resources-plugin:3.1.0:resources[m [1m(default-resources)[m @ [36morder-core[0;1m ---[m
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 0 resource
[INFO] 
[INFO] [1m--- [0;32mmaven-compiler-plugin:3.8.1:compile[m [1m(default-compile)[m @ [36morder-core[0;1m ---[m
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 151 source files to C:\Users\P2932832\BPradhan\order-core\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[14,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[15,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[42,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[43,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[39,60] cannot find symbol
  symbol:   class OrderRequest
  location: class com.spectrum.sci.controllers.OrderController
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[39,11] cannot find symbol
  symbol:   class OrderResponse
  location: class com.spectrum.sci.controllers.OrderController
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[55,36] cannot find symbol
  symbol:   class OrderRequest
  location: class com.spectrum.sci.service.OrderDetailsService
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[55,16] cannot find symbol
  symbol:   class OrderResponse
  location: class com.spectrum.sci.service.OrderDetailsService
[INFO] 8 errors 
[INFO] -------------------------------------------------------------
[INFO] [1m------------------------------------------------------------------------[m
[INFO] [1;31mBUILD FAILURE[m
[INFO] [1m------------------------------------------------------------------------[m
[INFO] Total time:  21.704 s
[INFO] Finished at: 2020-03-13T13:52:35-06:00
[INFO] [1m------------------------------------------------------------------------[m
[ERROR] Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile[m [1m(default-compile)[m on project [36morder-core[m: [1;31mCompilation failure[m: Compilation failure: 
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[14,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[15,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[42,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[43,30] package com.spectrum.tos.model does not exist
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[39,60] cannot find symbol
[ERROR]   symbol:   class OrderRequest
[ERROR]   location: class com.spectrum.sci.controllers.OrderController
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/controllers/OrderController.java:[39,11] cannot find symbol
[ERROR]   symbol:   class OrderResponse
[ERROR]   location: class com.spectrum.sci.controllers.OrderController
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[55,36] cannot find symbol
[ERROR]   symbol:   class OrderRequest
[ERROR]   location: class com.spectrum.sci.service.OrderDetailsService
[ERROR] /C:/Users/P2932832/BPradhan/order-core/src/main/java/com/spectrum/sci/service/OrderDetailsService.java:[55,16] cannot find symbol
[ERROR]   symbol:   class OrderResponse
[ERROR]   location: class com.spectrum.sci.service.OrderDetailsService
[ERROR] -> [1m[Help 1][m
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[ERROR] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

【问题讨论】:

  • 什么是tos-base?
  • 这是另一个项目,其中包含我们所有项目的基本功能。并且 order-core 依赖于这个项目。我可以为 tos-base 项目创建 jar 文件,它位于 .m2/repository 以及我的本地存储库中。
  • 可以添加错误信息吗?
  • 编辑帖子以在帖子底部添加错误。
  • 您使用的是 Nexus 或 Artifactory 等存储库吗? com.spectrum.tos:tos-base:1.0:jar 是否存在依赖项?如果没有,如果您进行了更改,您的安装(上述项目上的mvn install)是否首先安装了 tos-base 依赖项? (最后但并非最不重要的一点是,您可能想查看项目反应器,以便 Maven 知道如何正确编译您的项目)。

标签: maven-3


【解决方案1】:

尝试mvn -U clean install从你的远程仓库重新更新本地仓库,如果你的本地仓库.m2/com/spectrum/tos下正确安装了tos-base依赖,那么你应该检查1.0版本是否真的包含缺少包也许你应该升级这个依赖。

【讨论】:

  • 这是我的本地存储库。 C:\Users\P2932832\.m2\repository\com\spectrum\tos\tos-base\1.0>jar -tvf tos-base-1.0.jar 这里是文件 2448 Fri Mar 13 11:00:54 MDT 2020 BOOT-INF/classes/com/spectrum/tos/model/Order.class 733 Fri Mar 13 11:00:56 MDT 2020 BOOT-INF/classes/com/spectrum/tos/BaseApplication.class 2805 Fri Mar 13 11:00 :54 MDT 2020 BOOT-INF/classes/com/spectrum/tos/model/OrderRequest.class。我有所有的课程,我今天自己创建了 tos-base-1.0.jar。我还在eclipse中做了maven update project来同步。 mvn -U clean install 没有帮助并得到同样的错误。
  • 我尝试构建另一个依赖 tos-base 的项目。我得到了同样的错误包 com.spectrum.tos.builder 不存在。我试图删除 .m2/repository 中的文件夹并再次创建 jar 并遇到同样的问题。不知道如何解决问题。
  • 我可以从您的类位置 (/BOOT-INF) 中看到您正在使用 Spring Boot 应用程序作为依赖项,这导致编译失败
  • 这个问题和你的类似stackoverflow.com/questions/53679361/…
  • 瓦法,非常感谢。我尝试放置 exec classifier ,它起作用了。由于推荐的方法是模块化。我做了同样的事情,效果也很好。
猜你喜欢
  • 2020-10-07
  • 1970-01-01
  • 2012-08-15
  • 2014-11-27
  • 1970-01-01
  • 2017-04-21
  • 1970-01-01
  • 2014-06-23
  • 1970-01-01
相关资源
最近更新 更多