开发者

Using Tomcat within Eclipse for a Maven project

开发者 https://www.devze.com 2023-03-23 14:29 出处:网络
I have a multi-module Maven project. Here i开发者_如何学Gos how it is structured: cca-workflow (parent project)

I have a multi-module Maven project. Here i开发者_如何学Gos how it is structured:

  1. cca-workflow (parent project)
  2. cca-commons (jar)
  3. cca-models (jar)
  4. cca-wsclient (jar)
  5. cca-business (jar)
  6. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号