How to add WAR inside EAR with Maven

前端 未结 2 805
忘掉有多难
忘掉有多难 2020-12-08 03:10

I have EAR with an application and I need to extend this app with my own code that is packaged as a WAR. Is there a maven plugin that can help me with putting the WAR inside

2条回答
  •  粉色の甜心
    2020-12-08 03:27

    I'd create a new module that has ear.

    In the dependencies for this ear module, include your war module:

    
        com.your.group.id
        your-war-artifact
        your-war-version
        war
    
    

    Now in the build plugins for this ear module, include the maven-ear-plugin like, e.g.:

    
        maven-ear-plugin
        2.3.2
        
            MyEarFile
            5
            ${basedir}/src/main/application/META-INF
            
                
                    com.your.group.id
                    your-war-artifact
                    YouWarFile.war
                    YouWarFile.war
                    /appname
                
            
        
    
    

    You can change the specific configuration values for the webModule as required.

    Now create a parent module (with pom) and add the war module and the ear module to it. Make sure you set the of the war and ear modules corrently.

    When you run mvn package for this new parent, a war file will be built by the war module and an ear file (containing the war) will be built by the ear module.

提交回复
热议问题