Ear 项目动态 webapplication 和 maven

Ear project dynamic webapplication and maven

我必须创建一个动态网络应用程序。我必须从中创建一个耳文件。我也想用maven。在 eclipse 中执行此操作的最佳方法是什么?

我找到了 "maven-archetype-j2ee-simple" 原型 (Create complete EAR Project with Maven and Eclipse Helios)。谁能告诉我必须将什么放入哪个文件夹(controllers、test、jsp-sites、java 类)以及如何创建 ear 文件。

如果我 运行 maven 我得到错误

 Child module */site of */pom.xml does not exist

我只需要删除根 pom.xml 中的 <module>site</module> 即可消除此错误,但我什至不知道它在做什么。为什么这个原型会出错?

此致!

这个原型中似乎有一个错误(从 ejb 模块的外观来看它很旧),您可以从 parent pom 中删除站点模块,我认为它应该是Maven 站点。

不过,我建议您不要使用此原型。

从 maven-archetype-webapp 创建一个 war 项目,然后创建您自己的 parent 和您自己的 ear 项目来打包 war。

parent 看起来像这样:

<modules>
        <module>poc-war</module>
        <module>poc-ear</module>
</modules>

ear pom 将依赖于 war 项目并使用 maven ear 插件生成 ear:

<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/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <parent>
                <groupId>net.isban</groupId>
                <artifactId>poc</artifactId>
                <version>1.0-SNAPSHOT</version>
        </parent>

        <artifactId>poc-ear</artifactId>
        <packaging>ear</packaging>

        <description>EAR deployment </description>
        <name>FMIS EAR</name>

        <dependencies>
                <dependency>
                        <groupId>net.isban</groupId>
                        <artifactId>poc-war</artifactId>
                        <version>${project.version}</version>
                        <type>war</type>
                </dependency>
        </dependencies>

        <build>
                <finalName>${project.artifactId}-${project.version}</finalName>
                <plugins>
                        <plugin>
                                <artifactId>maven-ear-plugin</artifactId>
                                <version>2.10.1</version>
                                <configuration>
                                        <skinnyWars>false</skinnyWars>
                                        <filtering>true</filtering>
                                        <modules>
                                                <webModule>
                                                        <groupId>net.isban</groupId>
                                                        <artifactId>poc-war</artifactId>
                                                        <contextRoot>/poc</contextRoot>
                                                </webModule>
                                        </modules>
                                </configuration>
                        </plugin>
                </plugins>
        </build>

</project>