Using Tomcat within Eclipse for a Maven project
I have a multi-module Maven project. Here i开发者_如何学Gos how it is structured:
- cca-workflow (parent project)
- cca-commons (jar)
- cca-models (jar)
- cca-wsclient (jar)
- cca-business (jar)
- cca-web (war)
The war project depends on the jar projects. In my parent project, I have a Maven properties file which at build time replaces some of my Spring properties e.g. web_service_url, port, wsdl etc. The project builds correctly with all the properties getting resolved.
The problem is when I try using Tomcat from within Eclipse using the maven-eclipse-plugin. This configures the project to be able to be deployed in tomcat, however it is not resolving the Maven properties into my Spring properties file which causes the deployment to fail.
You need to use m2eclipse, then you can use WTP with Tomcat.
Have you tried the maven tomcat plugin?
Edit: The plugin is painfully easy to use.
1) Add the plugin to your POM.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<warFile>target/myapp.war</warFile>
<url>http://localhost:8080/manager</url>
<username>username</username>
<password>password</password>
</configuration>
</plugin>
2) Ensure the username and password are good for the manager app. Tomcat has no admin users set up by default. You can add them by editing your conf/tomcat-users.xml
file;
<tomcat-users>
<role rolename="manager"/>
<user password="password" roles="manager" username="username"/>
</tomcat-users>
3) Deploy using the maven goal tomcat:deploy
.
Notes
Only use this on dev/test boxes, never on production/live. You should have a proper change management system on live. It also not a great idea to allow access to the manager app on live. You also should choose a proper username and password.
I have the same problem. For solving this issue. I have deleted the tomcat server configured in eclipse and added back again then issue got resolved.
Hope this helps.
精彩评论