Possible to run two webapps at once when developing with Maven/Eclipse?

前端 未结 5 1163
谎友^
谎友^ 2020-12-16 07:23

Here\'s the problem: we build webapps for clients. We also have an \"admin\" webapp that modifies some client data structures. Because of the nature of the data, both webapp

5条回答
  •  青春惊慌失措
    2020-12-16 08:12

    Yes, you can :) It's done by identifying one WAR module as the primary, copying all the other WARs into the primary's target dir, making a jetty.xml and telling Maven Jetty Plugin to use the jetty.xml. Here's how to copy the other WARs using Maven dependency plugin:

    
    org.apache.maven.plugins
    maven-dependency-plugin
    
        
            copy
            package
            
                copy
            
            
                
                    
                        com.foo
                        bar
                        ${project.version}
                        war
                        true
                        target/
                    
                
            
        
    
    

    You'll need to have the com.foo:bar dependency defined in the POM as well. Here's the contents of jetty.xml:

    
    

    
    
    
    
        
            
                
                    
                        
                            
                                
                                    
                                        
                                    
                                
                            
                        
                    
                
            
        
    
    
    
        /foo
        
            target/bar-${project.version}.war
        
    
    

    And here's how to tell Maven Jetty plugin to use the new jetty.xml:

    
    org.mortbay.jetty
    jetty-maven-plugin
    ${jetty.version}
    
        ${basedir}/jetty.xml
    
    

    Now kick off jetty:run-war goal from Eclipse and you should see all WARs deploying in one Maven Jetty plugin instance. I run this from command line and it works there, YMMV with Eclipse.

提交回复
热议问题