Using the Maven Eclipse Integration plugin
I you are experiencing problems I've found it helpful to try the command line tool mvn for debugging. As a rule of thumb, if it builds without errors command line, then you can run it in Eclipse (but tomcat has problems also, so you might need to clean work directory and clear caches every once in a while).
Other than that I really recommend using the Maven Eclipse Integration plugin! I use the version from Sonatypes plugin repo http://m2eclipse.sonatype.org/sites/m2e. There is a newer integration on the eclipse repo, but it works differently and I have not yet had time to investigate it's uses yet.
If your project is modular, it may help to setup the root project as a simple project (no Java , no Java EE). Then import the sub-projects as simple Java projects (again no Java EE). You can still activate dependency management and run the build targets through the project.
You only need to select the submodules required by your targeted project(s) by dependencies.
For any project that builds war files activate facets for java ee and configure context root under further configuration available (this can only be done once, why the option is missing in the screenshot, so do it right).
Then setup deployment assembly for your facated projects. All sibling projects (active in you workspace) should be added to deployment assembly and you also need to add the build path entry for maven dependencies to the deployment assembly. Once this is set up you can use the Run on server directive to boot your web apps.
I find it useful to always stay in pure java mode when coding maven projects. Any smart views in Eclipse only obscures what happens behind the scene, you get access to the specific editors by activating facated projects anyway!
There are two options.
First, Eclipse lets you do this, with a slight change of configuration (see also this detailed post)
- add Tomcat to the server list
- make the project "Dynamic web project" (Either through the creation wizard or through the facets section in the settings)
- add the project to tomcat, and configure its "Deployment assembly"
- double click tomcat from the list to open the configurations
- Change "Publishing" to "Never publish automatically" (this means the server won't get restarted when you hit ctrl+s)
- start tomcat in debug mode
This will still reflect code changes but won't restart the server.
Second, I've used the FileSync plugin for a long time:
- configure the plugin to send all classes from the bin director to
WEB-INF/classes of your tomcat installation (this is almost the same as configuring the deployment assembly)
- configure all other resources to go to their respective locations
- optionally, externalize all absolute paths from the filesync location settings to a single variable, and configure that variable in eclipse (thus you will be able to commit the filesync settings as well, if all members are using eclipse)
- add Tomcat to the Servers list in eclipse, configure the "Server locations" option to be "Use tomcat installation" (the screen opens when you double-click tomcat from the servers list)
- start tomcat in debug mode
It works perfectly for me that way. Every non-structural change is reflected immediately, without redeploy.
You can read more about the methods for hot-deploying here.
I also created a project that easily syncs the workspace with the servlet container.
I usually create an ant build file, loosely based on:
and use the 'install'/'remove' targets to deploy to a remote tomcat
Similar question here: Remote deploy Tomcat webapp from Eclipse
If you're talking about only developing on your local machine- you don't need an external plugin to eclipse, it has built in support for Tomcat and hot redeployment.