使用Maven 3设置Struts2 EAR项目 [英] Set-up a Struts2 EAR Project with Maven 3

查看:158
本文介绍了使用Maven 3设置Struts2 EAR项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Apache Ant + Apache Ivy 迁移到 Apache Maven ,用于新项目的生命周期管理。

I'm migrating from Apache Ant + Apache Ivy to Apache Maven for the lifecycle management of a new project.

我从来没有将Maven用于官方发布,所以我就是新手。

I've never used Maven for official releases, so I'm a total newbie on this.

目前我已经安装并配置了 Maven 3 M2Eclipse 插件,我用空白会议原型(struts2-archetype-convention),我可以部署到 JBoss 7 的项目。

Currently I have installed and configured Maven 3 and the M2Eclipse Plugin, and I've created a new Struts2 WAR project with The Blank Convention Archetype (struts2-archetype-convention), project that I'm able to deploy to JBoss 7.

在阅读了大量文章和StackOverflow答案后,我发现Maven的第一个规则是:一个项目,一个工件;

After reading tons of articles and StackOverflow answers I've figured out that the first rule of Maven is: one project, one artifact;

然后,要使用EAR,我需要三个项目: EAR WAR EJB < /强>;但这个答案表明我需要4个项目,而不是3个:一个 EAR ,一个 WAR ,一个 EJB ,一个 PARENT 。我认为EJB将是父...所以第一个问题是:

Then, to work with an EAR I need three projects: EAR, WAR, EJB; but this answer suggests that I need 4 projects, not three: one EAR, one WAR, one EJB, and one PARENT. I thought that the EJB would be the parent... so the first question is:


  • 这是正确的方法吗?

现在我已经开始使用Struts2 WAR了,第二个问题是:

And now that I've a working Struts2 WAR, the second question is:


  • 在EAR项目中(或者如果需要,在PARENT项目中)包含现有WAR的最佳(最干净,最常用)方法是哪种方式?

手动创建?生成其他 ear artifact Java-EE-webapp artifacts ,然后添加依赖项?任何假设的POM.xml的例子都将非常感激。

Creating it manually ? Generating some other ear artifact or Java-EE-webapp artifacts, and then add the dependencies ? Any example of an hypothetical POM.xml needed would be greatly appreciated.

推荐答案

我最终使用:


  1. JBoss Java EE 6 WebApp Archetype 生成WebApp,由四个项目组成:Parent,EAR,EJB,WAR:

  1. JBoss Java EE 6 WebApp Archetype to generate the WebApp, composed by four projects: Parent, EAR, EJB, WAR:

mvn archetype:generate \
        -DarchetypeArtifactId=jboss-javaee6-webapp-archetype \
        -DarchetypeGroupId=org.jboss.spec.archetypes \
        -DarchetypeVersion=7.0.2.CR2


  • Struts2空白约定原型生成WAR:

    mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
            -DartifactId=myWebApp \
            -DarchetypeGroupId=org.apache.struts \
            -DarchetypeArtifactId=struts2-archetype-convention \
            -DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
            -DremoteRepositories=http://struts.apache.org
    


  • 然后我手动将JBoss生成的WAR替换为Struts2生成的WAR。

  • Then I manually replaced the WAR generated by JBoss with the WAR generated by Struts2.

    我想这是最干净的方式。

    I guess it is the cleanest way.

    这篇关于使用Maven 3设置Struts2 EAR项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆