java Maven 循环依赖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11402489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven cycle dependency
提问by greengold
I'm new to Maven and Im trying to make my own Java EE Maven project with some frameworks... I have started with two modules and one parent module. The problem is that Im getting this error when Im issue mvn clean:
我是 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]
I know what cycle dependency is, but I can not see such a thing in my poms. Here They are: parent POM:
我知道循环依赖是什么,但我在我的 poms.xml 中看不到这样的东西。它们是:父 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 module:
网络模块:
<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 module:
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>
Please, can ypu explain to me why Im getting this error ? also, eclipse gives this error on pom file of web module: Missing artifact org.tepo:Jporto-web:war:0.0.1-SNAPSHOT:compile and Missing artifact org.tepo:Jporto-ejb:ejb:0.0.1-SNAPSHOT:compile on web module... Thank you for your help!
拜托,你能向我解释为什么我会收到这个错误吗?另外,eclipse 在 web 模块的 pom 文件中给出了这个错误: Missing artifact org.tepo:Jporto-web:war:0.0.1-SNAPSHOT:compile and Missing artifact org.tepo:Jporto-ejb:ejb:0.0.1-SNAPSHOT :compile on web module...谢谢你的帮助!
回答by Peter Lawrey
Your parent pom depends on your modules which depend on your parent pom.
您的父 pom 取决于您的模块,而这些模块又取决于您的父 pom。
What you could have done is add to your parent pom
你可以做的是添加到你的父 pom
<modules>
<module>module1</module>
<module>module2</module>
</module>
Your modules have to be subdirectories with the names you give them.
你的模块必须是你给它们命名的子目录。