英文:
maven error using intellij is referencing itself
问题
以下是您提供的内容的翻译部分:
主项目的 pom.xml 文件:
<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.clouddispatcher</groupId>
<artifactId>clouddispatcher</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>aws-manager</module>
</modules>
<dependencies>
<dependency>
<groupId>com.clouddispatcher</groupId>
<artifactId>aws-manager</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<aws.java.sdk.version>1.11.875</aws.java.sdk.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
模块的 pom.xml 文件:
<?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>clouddispatcher</artifactId>
<groupId>com.clouddispatcher</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aws-manager</artifactId>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
</dependency>
</dependencies>
</project>
当运行以下命令时:
mvn clean install
我一直在收到这个错误:
The build could not read 1 project -> [Help 1]
The project com.clouddispatcher:aws-manager:1.0-SNAPSHOT (C:\Dev\my\java\clouddispatcher\aws-manager\pom.xml) has 1 error
'dependencies.dependency. com.clouddispatcher:aws-manager:1.0-SNAPSHOT' for com.clouddispatcher:aws-manager:1.0-SNAPSHOT is referencing itself. @ com.clouddispatcher:clouddispatcher:1.0-SNAPSHOT, C:\Dev\my\java\clouddispatcher\pom.xml, line 23, column 21
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
(注意:由于代码部分不需要翻译,我只提供了翻译好的内容。)
英文:
I have this 2 simple pom.xml
main parent project and module which the project is using
main project pom.xml :
<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.clouddispatcher</groupId>
<artifactId>clouddispatcher</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>aws-manager</module>
</modules>
<dependencies>
<dependency>
<groupId>com.clouddispatcher</groupId>
<artifactId>aws-manager</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<aws.java.sdk.version>1.11.875</aws.java.sdk.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
and the module pom.xml :
<?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>clouddispatcher</artifactId>
<groupId>com.clouddispatcher</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aws-manager</artifactId>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
</dependency>
</dependencies>
</project>
now when I run :
mvn clean install
I keep getting this error :
The build could not read 1 project -> [Help 1]
The project com.clouddispatcher:aws-manager:1.0-SNAPSHOT (C:\Dev\my\java\clouddispatcher\aws-manager\pom.xml) has 1 error
'dependencies.dependency. com.clouddispatcher:aws-manager:1.0-SNAPSHOT' for com.clouddispatcher:aws-manager:1.0-SNAPSHOT is referencing itself. @ com.clouddispatcher:clouddispatcher:1.0-SNAPSHOT, C:\Dev\my\java\clouddispatcher\pom.xml, line 23, column 21
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
答案1
得分: 6
让我更详细地解释khmarbaise的要点:
- 父类不能拥有Java类。您需要从父类中移除这些类。
- 您不能定义循环依赖,即如果A是B的父类,则不能将B作为依赖项。
您需要重构您的项目以满足这些条件,例如,将这些类从父类移到第二个模块中。
英文:
Let me explain the points of khmarbaise in more detail:
- Parents cannot have Java classes. You need to remove the classes from the parent.
- You cannot define circular dependencies, i.e. if A is a parent of B, it cannot have B as dependency.
You need to refactor your project to meet these criteria, e.g. by moving the classes from the parent to a second module.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论