Tuesday, July 15, 2014

Create and configure the commons module in J2ee projects

How to create and configure the commons module in J2EE projects using maven

Step 1:  Create the commons project exampl: velsCommons with all the necessary util classes....

Step 2:  Include the velsCommonsproject as dependency in child projects pom.xml file as below.

         pom.xml
         ..

     <?xml version="1.0" encoding="UTF-8"?>

       <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>

      


        <dependency>
            <groupId>org.vels.common</groupId>
            <artifactId>vels-commons</artifactId>
            <version>0.0.1</version>
            <type>jar</type>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

.....
....

</project>

Step 3: Change your maven settings.xml(<USER_HOME>/.m2/settings.xml) to look for the referenced(commons module) jars in your local repository.

Location of the settings.xml file is C:/Users/<login name>/.m2 in windows...

<?xml version="1.0" encoding="utf-8"?>
<settings>
<localRepository>C:/Users/vselvaraj/.m2/repository/</localRepository>
...
....
...
...
</settings>



Note :  Incase if you are facing any class not found issue (class from commons module is not found) during the child module deployment. Make you have the WAS server publish settings as follows (server publish resources settings).


Choose the option " Run server with resources on Server".


While configuring the maven task  for the common module bamboo plan:

Use below goals for maven task in bamboo plan:   clean deploy






1 comment: