【发布时间】:2020-11-09 18:28:31
【问题描述】:
我需要创建一个EAR 文件以部署在JBoss EAP 7 上。我考虑构建一个如下的项目结构:
- rootproject
-- ear (ear)
-- web (war)
因此,对于 rootproject,我创建了一个新的 Simple Maven 项目(使用 Eclipse 06/2020),并带有以下 .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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jboss_test</groupId>
<artifactId>jboss_test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>jboss_ear_test</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.11.RELEASE</version>
</parent>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>ear</module>
<module>web</module>
</modules>
</profile>
</profiles>
</project>
因此,在其中,我创建了一个SpringBoot 2.2.11 项目(WEB),并带有以下.pom.xml:
....
....
<parent>
<artifactId>jboss_test</artifactId>
<groupId>jboss_test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<packaging>war</packaging>
<name>web-test</name>
<description>Spring Boot JBOSS</description>
.... // some dependencies
一个 Maven 模块使用了带有以下 .pom.xml 的耳朵:
....
....
<parent>
<artifactId>jboss_test</artifactId>
<groupId>jboss_test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>ear</artifactId>
<packaging>ear</packaging>
<name>ear-test</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<finalName>JBOSS-TEST_EAR</finalName>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>jboss_test</groupId>
<artifactId>web</artifactId>
<bundleFileName>JBOSS-TEST.war</bundleFileName>
<contextRoot>/TEST</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
当我尝试从根目录构建项目时,出现以下错误:
Artifact[war:jboss_test:web] is not a dependency of the project
你能帮我找出问题所在吗??
谢谢
【问题讨论】:
-
因为消息告诉你这个问题。您没有将 Web 部件定义为 ear 项目的依赖项......除此之外,我强烈建议您从 pom 中删除带有模块的配置文件,这没有任何意义,也没有与模块/配置文件相关的有用信息...
-
我怎样才能做到这一点??
-
将依赖项添加到您的 web 模块的 pom 中...
-
我试了一下,但我得到了更多的错误,你能写两行代码吗?我想创建一个包含我的 web .war 包的 EAR...为什么我必须在 pom of war 项目中声明 ear?
-
在你的
<artifactId>ear</artifactId>模块中定义依赖而不是在战争中.. 战争项目的 pom 中的耳朵也没有..
标签: spring-boot maven ear