我想构建具有EJB模块和WEB模块的maven项目,在WEB模块中需要EJB。
父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>http://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 时,它失败并显示:
[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]
问题出在哪里?我没有运气就浏览了类似的问题。谢谢。
答案 0 :(得分:2)
您已经定义了ejb模块的artifactId,如下所示:
<artifactId>OAuthLoginEJB</artifactId>
但不是
<artifactId>OAuthLogin-ejb</artifactId>
但你的依赖是这样的:
<dependencies>
<dependency>
<groupId>cz.literak.oauth</groupId>
<artifactId>OAuthLogin-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
</dependencies>