【问题标题】:EAR project conversion to maven - web module stop workingEAR 项目转换为 Maven - Web 模块停止工作
【发布时间】:2017-04-24 22:31:37
【问题描述】:

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

  • EAR 作为下面的包装器
  • WEB模块
  • EJB 模块

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

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

我想为整个解决方案添加 maven 支持,因此根据找到的文章我使用了向导:右键单击项目“配置”->“转换为 maven 项目”。我先是为 ejb 和 web 模块做的,然后是耳朵。我还修改了ear pom.xml文件和application.xml文件。

此转换后,我的网络模块停止工作。尝试查看欢迎页面返回错误 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 配置,但没有一篇对我有帮助。我遗漏了什么?

提前谢谢大家。

【问题讨论】:

    标签: eclipse jakarta-ee ejb war ear


    【解决方案1】:

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

    主要项目

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

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

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

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

    【讨论】:

    • 好的。因此,如果我很好理解,我应该将所有项目(包括第一个耳朵)包含在父项目中?应该是一个什么样的项目?
    • 这是一个pom项目
    • 这个项目只包含子项目,如果你看一下netbeans的示例项目你就完全理解了结构
    猜你喜欢
    • 1970-01-01
    • 2011-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    相关资源
    最近更新 更多