Wednesday 29 February 2012

Deploy to Tomcat instance on Eclipse - Steps for Maven enabled projects.

A while ago I was looking for an approach to enable Maven deploy Java web Applications to Tomcat server installed on my eclipse IDE. Did some googling around and did not find anything relevant to my search, and so came up with this approach.
  1. Expand Servers directory as shown in your projects package view
  2. Create a new dir = instances
  3. Open Server view from -> Window -> Show Percpective -> Servers
  4. Double click on the server instance to view its config overview.
  5. On Configuration path: point it to "Servers/tc-6.0.32-config"

  6. From "Server Locations" select the radio button, select "Use custom location"
  7. Server path: point it to "Servers\tc-6.0.32-config\instances"
    Note: Your final config overview should look something like this:
























  8. Now lets save it and ask Maven to generate the target output to our instances directory created above.
  9. Ctrl + S to save the changes.
  10. In your POM file add this line:
          
            org.apache.maven.plugins
            maven-war-plugin
            ${war.plugin.version}
            
              
                ../Server/ts-6.0.32/instance/webapps/name_of_project_for_easy_identification
              
           [..] 
           
          
    
  11. Right click your Maven project select Run As -> build or alternatively execute:
      clean install -X -Dmaven.test.skip.exec=true
    
  12. Select your Servers directory and refresh. Maven will push build files to both targets and your instances/webapps location described above.
  13. Finally Start your server and job done.
Hope it helps you.

No comments:

Post a Comment