【问题标题】:Maven cycle dependencyMaven 循环依赖
【发布时间】:2012-07-09 20:20:04
【问题描述】:

我是 Maven 新手,我正在尝试使用一些框架制作我自己的 Java EE Maven 项目... 我从两个模块和一个父模块开始。 问题是当我发出 mvn clean 时出现此错误:

[ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='org.tepo:Jporto-web:0.0.1-SNAPSHOT'}' and 'Vertex{label='org.tepo:Jporto-ejb:0.0.1-SNAPSHOT'}' introduces to cycle in the graph org.tepo:Jporto-ejb:0.0.1-SNAPSHOT --> org.tepo:Jporto-web:0.0.1-SNAPSHOT --> org.tepo:Jporto-ejb:0.0.1-SNAPSHOT -> [Help 1]

我知道什么是循环依赖,但我在我的 poms 中看不到这样的东西。他们来了: 父 POM:

<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>org.tepo</groupId>
  <artifactId>Jporto</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>jsf library tutto</name>
  <description>fiesta prego grande</description>
  <dependencies>

        <dependency>
        <groupId>org.tepo</groupId>
        <artifactId>Jporto-ejb</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>ejb</type>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.tepo</groupId>
        <artifactId>Jporto-web</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
        <scope>compile</scope>
    </dependency>
 </dependencies>

  <modules>
    <module>Jporto-ejb</module>
    <module>Jporto-web</module>
  </modules>

  <build>  
  <plugins>  
    <plugin>  
      <artifactId>maven-compiler-plugin</artifactId>  
      <inherited>true</inherited>  
      <configuration>  
        <source>1.6</source>  
        <target>1.6</target>  
        <encoding>UTF-8</encoding>  
        <version>2.5.1</version>
      </configuration>  
    </plugin>  
    <plugin>  
      <artifactId>maven-resources-plugin</artifactId>  
      <configuration>  
        <encoding>UTF-8</encoding>  
      </configuration>  
    </plugin>  
    <plugin>  
      <artifactId>maven-ejb-plugin</artifactId>  
      <inherited>true</inherited>  
      <configuration>  
        <ejbVersion>3.1</ejbVersion>  
      </configuration>  
    </plugin>  
  </plugins>  
</build>  

</project>

WEB模块:

<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>

  <parent>
    <artifactId>Jporto</artifactId>
    <groupId>org.tepo</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>Jporto-web</artifactId>
  <groupId>org.tepo</groupId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencies>    
    <dependency>  
  <groupId>javax.jms</groupId>  
  <artifactId>jms</artifactId>  
  <version>1.1</version>  
  <scope>provided</scope>  
</dependency> 

<dependency>  
  <groupId>javax.transaction</groupId>  
  <artifactId>jta</artifactId>  
  <version>1.1</version>  
  <scope>provided</scope>  
</dependency>  

<dependency>  
  <groupId>org.hibernate</groupId>  
  <artifactId>hibernate-core</artifactId>  
  <version>4.0.0.Final</version>  
  <scope>provided</scope>  
</dependency>  

<dependency>  
  <groupId>org.hibernate</groupId>  
  <artifactId>hibernate-entitymanager</artifactId>  
  <version>4.0.0.Final</version>  
  <scope>provided</scope>  
</dependency>  

<dependency>  
  <groupId>org.hibernate.javax.persistence</groupId>  
  <artifactId>hibernate-jpa-2.0-api</artifactId>  
  <version>1.0.1.Final</version>  
  <scope>provided</scope>  
</dependency>  

<dependency>  
  <groupId>org.jboss.spec.javax.servlet</groupId>  
  <artifactId>jboss-servlet-api_3.0_spec</artifactId>  
  <version>1.0.0.Final</version>  
  <scope>provided</scope>  
</dependency>  

<dependency>  
  <groupId>javax.faces</groupId>  
  <artifactId>javax.faces-api</artifactId>  
  <version>2.1</version>  
  <scope>provided</scope>  
</dependency>  



  </dependencies>
</project>

EJB 模块:

<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>
  <parent>
    <artifactId>Jporto</artifactId>
    <groupId>org.tepo</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <groupId>org.tepo</groupId>
  <artifactId>Jporto-ejb</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ejb</packaging>

  <dependencies>  

    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-ejb3</artifactId>
        <version>7.1.0.CR1b</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

拜托,你能解释一下我为什么会收到这个错误吗? 此外,eclipse 在 web 模块的 pom 文件中给出了这个错误: Missing artifact org.tepo:Jporto-web:war:0.0.1-SNAPSHOT:compile 和 缺少工件 org.tepo:Jporto-ejb:ejb:0.0.1-SNAPSHOT:compile on web module... 感谢您的帮助!

【问题讨论】:

    标签: java maven dependencies


    【解决方案1】:

    你的父 pom 依赖于你的模块,而你的模块又依赖于你的父 pom。

    你可以做的是添加到你的父 pom

    <modules>
       <module>module1</module>
       <module>module2</module>
    </module>
    

    您的模块必须是具有您给它们的名称的子目录。

    【讨论】:

    • 是的,这就是我在父 POM 中的内容。您可以在我发布的第一个代码 sn-p 中看到它...
    • 是的,但是您的项目既定义为模块又定义为依赖项。只需删除依赖项就可以了。
    • 好吧,成功了!我发誓我已经在一些教程中阅读过它......:/谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-15
    • 2016-06-17
    • 2011-11-05
    • 2013-05-04
    • 2012-05-04
    相关资源
    最近更新 更多