gpt4 book ai didi

Maven 多模块项目,不解决依赖关系

转载 作者:行者123 更新时间:2023-12-04 18:30:37 26 4
gpt4 key购买 nike

我有一个无法编译的多模块 Maven 项目。我的本地网络上有一个 Nexus 存储库,它正在工作(IntelliJ Idea 能够解决我仅驻留在该存储库中的依赖项),并且我正在通过 Jetbrains TeamCity 构建。我相当肯定 TeamCity 正在工作,因为我设置的其他几个构建配置仍然有效(使用相同的 settings.xml)。对于可能导致问题的原因,我有点茫然。这是我的pom文件:

父pom:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.company.product.plugins</groupId>
<artifactId>plugin-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>product-wireless-plugin</module>
<module>product-paging-plugin</module>
</modules>

<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<pluginRepositories>
<pluginRepository>
<id>autoincrement-versions-maven-plugin</id>
<name>autoincrement-versions-maven-plugin</name>
<url>http://autoincrement-versions-maven-plugin.googlecode.com/svn/repo</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>autoincrement-versions-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<executions>
<execution>
<id>update-pom-versions</id>
<goals>
<goal>increment</goal>
<goal>commit</goal>
</goals>
<phase>compile</phase>
<configuration>
<autoIncrementVersion>true</autoIncrementVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>

</project>

产品无线pom:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>com.company.product.plugins</groupId>
<artifactId>product-wireless-plugin</artifactId>
<version>0.1.2</version>

<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.company.product</groupId>
<artifactId>product-common</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>

</project>

产品分页pom:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>com.company.product.plugins</groupId>
<artifactId>product-paging-plugin</artifactId>
<version>0.1.2</version>

<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.company.product</groupId>
<artifactId>product-common</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>

</project>

我得到的错误是:

com.company.product.plugins:product-wireless-plugin [13:54:16][com.company.product.plugins:product-wireless-plugin] Importing data from 'C:/TeamCity/buildAgent/work/40ac813105cf8bd7/product-wireless-plugin/target/surefire-reports/TEST-*.xml' with 'surefire' processor [13:54:16][com.company.product.plugins:product-wireless-plugin] Surefire report watcher [13:54:16][com.company.product.plugins:product-wireless-plugin] Downloading: repolocation/nexus/content/groups/public/com/company/product/product-parent/0.9.0/product-parent-0.9.0.pom [13:54:16][com.company.product.plugins:product-wireless-plugin] Failed to execute goal on project product-wireless-plugin: Could not resolve dependencies for project com.company.product.plugins:product-wireless-plugin:jar:0.1.2: Failed to collect dependencies for [com.company.product:product-common:jar:0.9.1 (compile)]



我在尝试调试时不知所措……有人有什么建议吗?

最佳答案

有几种方法/工具可以解决此类问题。

  • 对于这个“无法解决依赖关系”错误,构建日志中几乎总是有更详细的错误消息和/或堆栈跟踪。 Maven 日志实际上非常冗长,以至于必须在构建失败后的几个屏幕上搜索“根”错误消息。
  • 使用 -X 重新运行构建旗帜。这里是 documentation of Maven command line switches
  • 另一种选择是使用 mvn dependency:tree检查传递依赖的完整图。 mvn help:effective-pom是另一个有用的工具,它在考虑您的 settings.xml、任何事件配置文件等之后打印出 pom.xml。同样 mvn help:active-profiles
  • 关于Maven 多模块项目,不解决依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17176085/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com