Using Tomcat within Eclipse for a Maven project

若如初见. 提交于 2020-03-23 08:17:05

问题


I have a multi-module Maven project. Here is 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.


回答1:


You need to use m2eclipse, then you can use WTP with Tomcat.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/6870217/using-tomcat-within-eclipse-for-a-maven-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!