EAR 项目转换为 Maven - Web 模块停止工作

EAR project conversion to maven - web module stop working

我是 EAR 应用程序开发的新手。我正在尝试使用以下结构构建应用程序:

(我使用 Red Hat JBoss Developer Studio 作为 IDE 和 wildfly 作为服务器)

创建上述结构后,我对其进行了测试 - 一切正常。

我想为整个解决方案添加 Maven 支持,因此根据我使用向导找到的文章:右键单击项目 "Configure" -> "Convert to maven project"。我首先为 ejb 和 web 模块做了它,然后为 ear。我还修改了 ear pom.xml 文件和 application.xml 文件。

这次转换后我的网络模块停止工作。尝试查看欢迎页面 returns 错误 404。

您可以在下面找到 EAR 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>sri3</groupId>
  <artifactId>sri3</artifactId>
  <version>1.0.0</version>
  <packaging>ear</packaging>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <earSourceDirectory>EarContent</earSourceDirectory>
          <version>7</version>
          <defaultLibBundleDir>lib</defaultLibBundleDir>
          <webModule>
            <groupId>sri3.web</groupId>
            <artifactId>sri3.web</artifactId>
          </webModule>
          <ejbModule>
            <groupId>sri3.ejb</groupId>
            <artifactId>sri3.ejb</artifactId>
          </ejbModule>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>sri3.web</groupId>
        <artifactId>sri3.web</artifactId>
        <version>1.0.0</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>sri3.ejb</groupId>
        <artifactId>sri3.ejb</artifactId>
        <version>1.0.0</version>
        <type>ejb</type>
    </dependency>
  </dependencies>
</project>

您可以在下面找到 EAR application.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
  <display-name>sri3</display-name>
  <module>
    <web>
      <web-uri>sri3.web.war</web-uri>
      <context-root>sri3.web</context-root>
    </web>
  </module>
  <module>
    <ejb>sri3.ejb.jar</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>

我找到了几篇文章和问题,其中对正确的 EAR 配置进行了广泛的描述,但其中 none 对我有所帮助。我犯了什么错误?

提前致谢。

你应该为 maven 构建一个项目,如下所示:

主要项目

--------子项目(EJB)

--------子项目(WEB)

--------儿童项目 (EAR)

如果你有一个 netbeans ,如果你 select maven 企业模板,netbeans 构建一个简单的项目 祝你好运