本文介绍了Maven中的模块间依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想构建具有EJB模块和WEB模块的Maven项目,而在WEB模块中需要EJB.
I want to build maven project having EJB module and WEB module, where EJB is needed in WEB module.
父pom.xml
<modelVersion>4.0.0</modelVersion> <groupId>cz.literak.oauth</groupId> <artifactId>OAuthLogin</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>OAuthLogin-web</module> <module>OAuthLogin-ejb</module> </modules> <name>OAuthLogin JEE Skeleton</name> <url>www.literak.cz/OAuthLogin/</url>EJB pom.xml
<parent> <artifactId>OAuthLogin</artifactId> <groupId>cz.literak.oauth</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>OAuthLoginEJB</artifactId> <version>1.0-SNAPSHOT</version> <packaging>ejb</packaging> <name>OAuthLoginEJB Beans</name>WEB pom.xml
<parent> <artifactId>OAuthLogin</artifactId> <groupId>cz.literak.oauth</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>OAuthLoginWEB</artifactId> <packaging>war</packaging> <name>OAuthLogin Webapp</name> <dependencies> <dependency> <groupId>cz.literak.oauth</groupId> <artifactId>OAuthLogin-ejb</artifactId> <version>1.0-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies>Intellij Idea告诉我该版本未知.当我在父模块中运行 mvn clean install 时,它失败并显示:
Intellij Idea tells me that version is unknown. When I run mvn clean install in parent module, it fails with:
[ERROR] Failed to execute goal on project OAuthLoginWEB: Could not resolve dependencies for project cz.literak.oauth:OAuthLoginWEB:war:1.0-SNAPSHOT: Could not find artifact cz.literak.oauth:OAuthLogin-ejb:jar:1.0-SNAPSHOT -> [Help 1]问题出在哪里?我没有运气就浏览了类似的问题.谢谢.
Where is the issue? I browsed similar questions without luck. Thanks.
推荐答案您已经定义了ejb模块的artifactId,如下所示:
You have defined the artifactId of your ejb module like this:
<artifactId>OAuthLoginEJB</artifactId>但不是
<artifactId>OAuthLogin-ejb</artifactId>但您的依赖程度是这样的:
BUT YOUR DEPENDENCY is like this:
<dependencies> <dependency> <groupId>cz.literak.oauth</groupId> <artifactId>OAuthLogin-ejb</artifactId> <version>1.0-SNAPSHOT</version> <type>ejb</type> </dependency> </dependencies>更多推荐
Maven中的模块间依赖
发布评论