I am developing a web application with the Java and Maven build system, and the web server is Tomcat 7.0.12. After packing the entire project into a WAR file in the \ target directory from the Maven build command, I have to copy it to the webapps folder of Tomcat home in order to run it. This is very inconvenient, especially when I modified some source files, because I have to do all this (build, copy to Tomcat, run it). I studied some articles about Maven, Tomcat, Eclipse on this issue, but there is no result. Could you help me: 1. How to get Tomcat to run the WAR file in the target directory of the project, which is directly created by the Maven team? No need to copy / paste the WAR file and restart Tomcat? 2. How to configure Tomcat to debug a web application on Eclipse? Thank you very much!
By the way, I read and tried many times to configure Tomcat, Maven and pom files. But I donβt know what kind of configuration, because there are so many tips! Could you provide a specific configuration example for me? Here are my configuration files:
Tomcat tomcat-users.xml
<role rolename="manager-gui"/> <user username="admin" password="" roles="manager-gui"/> **<role rolename="manager"/> <user username="admin" password="" roles="manager"/>** <role rolename="admin-gui"/> <user username="admin" password="" roles="admin-gui"/>
Maven.xml Settings
Cat admin
And the project pom.xml file:
<build> <finalName>my-project</finalName> <defaultGoal>package</defaultGoal> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <server>tomcat</server> <warFile> ${project.build.directory}/${project.build.finalName}.war</warFile> </configuration> </plugin> </plugins> // Other plugins </build>
Details: If I started mvn tomcat: deploy before starting the Tomcat instance, the returned error is: "Unable to call the Tomcat manager: Connection failed: connect." Otherwise, if the Tomcat instance was started before calling mvn tomcat: deploy, the error is: "Unable to call the Tomcat manager: the server returned an HTTP: 403 response code for the URL: http: // localhost: 8080 / manager / deploy? Path =% 2Fmy -project & war = ... "
source share