Multi Module Maven2 Project with WTP

谁都会走 提交于 2019-12-06 01:52:22

问题


I'm having a hard time to make my Maven2 multi module project, with a deep project structure, appear as a single ear (with its dependencies - which includes 1 war, 2 ejbs and 1 jar) to be deployed in my JBOSS 5 server inside my Eclipse Ganymede (tab Servers).

I've been trying to use Maven Eclipse Plugin to turn my projects into a WTP project without success. Therefore they appear to be deployed in the server they appear as separated projets.

My project has 1 war, 2 ejbs and 1 jar that must be packaged inside an ear, each of the "subprojects" is a separate module.

Project's pom.xml (type pom):

...

<modules>
   <module>ejb1</module>
   <module>ejb2</module>
   <module>war</module>
   <module>jar</module>
   <module>ear</module>
</modules>

...

The ear module is only responsable to pack the other modules together.

Is there a way to tell eclipse (ganymede) that all those projects (ejbs, war and jar) are inside the ear module so I can deploy the ear in the server?


回答1:


What you want to do is have maven create the eclipse projects via mvn eclipse:eclipse This might be helpful.




回答2:


try m2eclipse (google it) and install the WTP integration tool, create a project using the maven wizard, change the type to pom in the pom xml editor, create a sub modules from the pom and that adds it as child, if its a web project it get the WTP behavior i.e it can be deployed to a j2ee container ( jboss / tomcat ), add a dep to the web module for ejb module in the web pom etc, deploy the web app to the container




回答3:


Installing the m2eclipse with the optional WTP configuration worked for me. I also added the following to my parent pom to ensure the right natures and builders in the eclipse files

This yields eclipse .project files that are ready for m2eclipse. then I can Update the project files using m2eclipse allowing hot deploy the webapp and its dependencies

<build>
  ...
        <plugin>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.5.1</version>
      <!--
      Eclipse project natures: http: //vikashazrati.wordpress.com/2007/12/22/adding-project-nature-to-your-maven-pomxml/
      Maven-eclipse-plugin: http: //maven.apache.org/plugins/maven-eclipse-plugin/
      -->
      <configuration>
      <additionalProjectnatures>
      <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
      <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
      <projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
      <projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
      <projectnature>org.eclipse.jdt.core.javanature</projectnature>
      <projectnature>org.eclipse.wst.jsdt.core.jsNature</projectnature>
      <projectnature>org.maven.ide.eclipse.maven2Nature</projectnature>
      </additionalProjectnatures>
      <buildcommands>
       <buildcommand>org.eclipse.wst.jsdt.core.javascriptValidator</buildcommand>
       <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
       <buildcommand>org.eclipse.wst.common.project.facet.core.builder</buildcommand>
       <buildcommand>org.eclipse.wst.validation.validationbuilder</buildcommand>
       <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
          <buildcommand>org.maven.ide.eclipse.maven2Builder</buildcommand>

      </buildcommands>
      </configuration>

  </plugin>



回答4:


use -Dwtpversion=2.0 parameter of maven or on command line mvn -Dwtpversion=2.0 in super pom project. i use m2eclipse plugin but has got some issues for multi module project. I use m2eclipse plugin for dependency management. If i want to clean, install etc. all project with super pom, i do it on command line. Also project properties must check in eclipse. Project Facets, Java EE Module dependencies must check. You can also export to ear project, but be carefull to check maven modules is compiled after changing.



来源:https://stackoverflow.com/questions/922138/multi-module-maven2-project-with-wtp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!