JBoss Maven example: building a Java EE 6 application

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

jboss maven jboss maven jboss mavenIn this tutorial we will show how to create a basic Java EE 6 application which will run on JBoss AS 7 using Maven. Apache Maven can provide benefits for your jave ee projects by employing standard conventions and practices to accelerate your development cycle while at the same time helping you achieve a higher rate of success.

Once you have installed Maven, we will generate an archetype of a project. An archetype is a very simple artifact, that contains the project prototype you wish to create. There are lots of prototypes available so you will need to provide the archetypeArtifactId and the archetypeGroupId. In our example we will choose the jboss-javaee6-webapp archetypeArtifactId and the org.jboss.spec.archetypes archetypeGroupId:

$ mvn archetype:generate  -DarchetypeArtifactId=jboss-javaee6-webapp  \ 
-DarchetypeGroupId=org.jboss.spec.archetypes \
-DgroupId=com.mastertheboss \
-DartifactId=as7example -DinteractiveMode=false


[INFO] Parameter: groupId, Value: com.mastertheboss
[INFO] Parameter: artifactId, Value: as7example
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mastertheboss
[INFO] Parameter: packageInPathFormat, Value: com/mastertheboss
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mastertheboss
[INFO] Parameter: name, Value: Java EE 6 webapp project
[INFO] Parameter: groupId, Value: com.mastertheboss
[INFO] Parameter: artifactId, Value: as7example
[INFO] project created from Archetype in dir: C:\maven\as7example
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

The following project structure has been created for you:

C:\MAVEN\AS7EXAMPLE
¦   .factorypath
¦   pom.xml
¦   readme.html
¦
+---.settings
¦
+---src
    +---main
    ¦   +---java
    ¦   ¦   +---com
    ¦   ¦       +---mastertheboss
    ¦   ¦           +---controller
    ¦   ¦           ¦       MemberRegistration.java
    ¦   ¦           ¦
    ¦   ¦           +---data
    ¦   ¦           ¦       MemberListProducer.java
    ¦   ¦           ¦
    ¦   ¦           +---model
    ¦   ¦           ¦       Member.java
    ¦   ¦           ¦
    ¦   ¦           +---rest
    ¦   ¦           ¦       JaxRsActivator.java
    ¦   ¦           ¦       MemberResourceRESTService.java
    ¦   ¦           ¦
    ¦   ¦           +---util
    ¦   ¦                   Resources.java
    ¦   ¦
    ¦   +---resources
    ¦   ¦   ¦   import.sql
    ¦   ¦   ¦
    ¦   ¦   +---META-INF
    ¦   ¦           persistence.xml
    ¦   ¦
    ¦   +---webapp
    ¦       ¦   index.html
    ¦       ¦   index.xhtml
    ¦       ¦
    ¦       +---resources
    ¦       ¦
    ¦       +---WEB-INF
    ¦           ¦   beans.xml
    ¦           ¦   faces-config.xml
    ¦           ¦
    ¦           +---templates
    ¦                   default.xhtml
    ¦
    +---test
        +---java
        ¦   +---com
        ¦       +---mastertheboss
        ¦           +---test
        ¦                   MemberRegistrationTest.java
        ¦
        +---resources
                arquillian.xml

Next step will be customizing the Maven pom.xml file