How To Practice A Modularized Ear Projection Inwards Maven

This post is i manner of creating a typical javaee6 maven projection that contains ear, web, ejb together with api. The output of course of written report is an ear file that contains (web, ejb together with api).

How it looks similar (assuming our tiptop projection is named ipiel):
+ipiel
 +ipiel-ear
 +ipiel-web
 +ipiel-api
 +ipiel-ejb

*Note that ipiel, tin every bit good endure a small-scale fry of a about other project, which could endure a original projection where ipiel is only a component.

How to practise the v listed maven projects inwards a higher house (I'm assuming you lot convey eclipse amongst maven plugin installed):
1.) ipiel (the original pom project)
  a.) In eclipse practise a novel maven project, skip archetype pick together with thus it volition entirely practise a maven projection that has a src folder no main/test.
  b.) groupId=com.ipiel
       artifactId=ipiel
       packaging=pom
       version=leave the default

2.) ipiel-api (where interface is declared that is shared betwixt ejb together with web)
  a.) Right click the ipiel projection together with pick out new->maven module
  b.) Since this volition comprise coffee files, pick out maven-archetype-quickstart, you lot tin filter "quickstart"
  c.) groupId=com.ipiel
       artifactId=ipiel-api
       packaging=jar
       version=leave the default
  d.) Create a aeroplane Bird together with add together a method fly.

3.) ipiel-ejb (the backing/manage bean)
  a.) Right click the ipiel projection together with pick out new->maven module
  b.) Since this volition comprise coffee files, pick out maven-archetype-quickstart, you lot tin filter "quickstart"

  c.) groupId=com.ipiel
       artifactId=ipiel-ejb
       packaging=ejb
       version=leave the default
  d.) Add dependency to ipiel-api, together with implement the Bird interface, inwards a aeroplane let's enjoin Eagle.
<dependency>  <groupId>com.ipiel</groupId>  <artifactId>ipiel-api</artifactId>  <version>0.0.1-SNAPSHOT</version> </dependency> 

4.) ipiel-web (the ui project, where you lot define your xhtml files)
  a.) Right click the ipiel projection together with pick out new->maven module
  b.) In the maven filter movement into "web" together with pick out org.codehaus.mojo.archetypes webapp-javaee6.
       It's a unproblematic spider web archetype together with nosotros ask to add together about files to it.
    1.) Add a novel beginning folder /src/main/resources.
    2.) Inside /src/main/resources practise ii folders /META-INF together with /WEB-INF
    3.) Normally nosotros convey beans.xml together with web.xml within /WEB-INF folder together with /META-INF contains MANIFEST.MF
  c.) groupId=com.ipiel
       artifactId=ipiel-web
       packaging=war
       version=leave the default
  d.) Make certain that you lot add together maven-war-plugin inwards pom.xml.
<plugin>  <artifactId>maven-war-plugin</artifactId>  <version>2.2</version>  <configuration>   <!-- In version 2.1-alpha-1, this was incorrectly named warSourceExcludes -->   <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>   <archive>    <manifest>     <addClasspath>true</addClasspath>     <classpathPrefix>lib/</classpathPrefix>    </manifest>   </archive>  </configuration> </plugin> 
  e.) The spider web projection is every bit good theme on ipiel-api, since it needs to telephone telephone it's backing edible bean from the ipiel-ejb project.

5.) ipiel-config (where I commonly house persistence together with resources files)
  a.) groupId=com.ipiel
       artifactId=ipiel-config
       packaging=pom
       version=leave the default
  b.) Create a novel maven module, together with select maven-archetype-quickstart, you lot tin filter "quickstart"
I defined where my resources are inwards this project:
<build>  <resources>   <resource>    <directory>src/main/resources</directory>    <filtering>true</filtering>   </resource>  </resources> </build> 

6.) ipiel-ear (the output project)
  a.) Create a novel maven module project, skip archetype selection, together with thus nosotros convey a basic maven project
  b.) groupId=com.ipiel
       artifactId=ipiel-ear
       packaging=ear
       version=leave the default
  c.) 
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.