Deploying project, created with Eclipse and Maven, to Tomcat

前端 未结 5 1595
孤街浪徒
孤街浪徒 2020-12-28 10:35

I\'m using Eclipse 3.5, Maven 2, m2eclipse and Tomcat 6. So i create Maven project for archetype webapp. This is pom.xml:



        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 10:50

    So then i want to deploy my web application to Tomcat. What I need to do? Maven install don't help. But if I create war by Maven install, i can import it to eclipse and deploy it to Tomcat by "Add and remove..." in server popup.

    Since you are using m2eclipse, my recommendation would be to deploy your application using the WTP. Assuming you have the Maven integration for WTP feature installed (from m2eclipse extras) and Tomcat configured as Server, just right-click on your project and select Run > Run on Server...

    Another option would be to run your application on Jetty (yes, I know that this is not what you're asking for but this is very valid option if you don't want to use the WTP). Add the following snippet to your pom:

    
      ...
      
        ...
        
          ...
          
            org.mortbay.jetty
            maven-jetty-plugin
            6.1.10
          
        
      
    
    

    And simply run mvn jetty:run to start an embedded Jetty server and deploy your application on it.

    The same can be achieved for Tomcat using the Tomcat Maven Plugin but unless you want to deploy to a remote Tomcat (see the Usage page), I don't see any advantage over the Maven Jetty Plugin.

    During development, I would use the first option (deploy with the WTP).

提交回复
热议问题