Maven在IntelliJ中出现的错误是引用自身。

huangapple go评论89阅读模式
英文:

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

Maven在IntelliJ中出现的错误是引用自身。

(注意:由于代码部分不需要翻译,我只提供了翻译好的内容。)

英文:

I have this 2 simple pom.xml
main parent project and module which the project is using
main project pom.xml :

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;



    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;com.clouddispatcher&lt;/groupId&gt;
    &lt;artifactId&gt;clouddispatcher&lt;/artifactId&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;modules&gt;
        &lt;module&gt;aws-manager&lt;/module&gt;
    &lt;/modules&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.clouddispatcher&lt;/groupId&gt;
            &lt;artifactId&gt;aws-manager&lt;/artifactId&gt;
            &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
            &lt;scope&gt;compile&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;properties&gt;
        &lt;aws.java.sdk.version&gt;1.11.875&lt;/aws.java.sdk.version&gt;
    &lt;/properties&gt;
    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.8.1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;source&gt;1.8&lt;/source&gt;
                    &lt;target&gt;1.8&lt;/target&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencyManagement&gt;
        &lt;dependencies&gt;

            &lt;dependency&gt;
                &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
                &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
                &lt;version&gt;${aws.java.sdk.version}&lt;/version&gt;
            &lt;/dependency&gt;
        &lt;/dependencies&gt;
    &lt;/dependencyManagement&gt;

&lt;/project&gt;

and the module pom.xml :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;parent&gt;
        &lt;artifactId&gt;clouddispatcher&lt;/artifactId&gt;
        &lt;groupId&gt;com.clouddispatcher&lt;/groupId&gt;
        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;/parent&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;artifactId&gt;aws-manager&lt;/artifactId&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;
            &lt;artifactId&gt;aws-java-sdk&lt;/artifactId&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/project&gt;

now when I run :

mvn clean install

I keep getting this error :

The build could not read 1 project -&gt; [Help 1]
  
  The project com.clouddispatcher:aws-manager:1.0-SNAPSHOT (C:\Dev\my\java\clouddispatcher\aws-manager\pom.xml) has 1 error
    &#39;dependencies.dependency. com.clouddispatcher:aws-manager:1.0-SNAPSHOT&#39; 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

Maven在IntelliJ中出现的错误是引用自身。

答案1

得分: 6

让我更详细地解释khmarbaise的要点:

  1. 父类不能拥有Java类。您需要从父类中移除这些类。
  2. 您不能定义循环依赖,即如果A是B的父类,则不能将B作为依赖项。

您需要重构您的项目以满足这些条件,例如,将这些类从父类移到第二个模块中。

英文:

Let me explain the points of khmarbaise in more detail:

  1. Parents cannot have Java classes. You need to remove the classes from the parent.
  2. 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.

huangapple
  • 本文由 发表于 2020年10月7日 22:30:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/64246267.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定