Thursday, February 20, 2014

using maven deploy the spring application in tomcat 7


tomcat-users.xml

<role rolename="manager"/>
    <role rolename="manager-gui"/>        
    <role rolename="admin"/>
    <role rolename="manager-script"/>
    <user password="admin" roles="admin,manager,manager-gui,manager-script" username="admin"/>


pom.xml

<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>  
                <artifactId>tomcat7-maven-plugin</artifactId>  
                <version>2.1</version>  
                <configuration>  
                    <url>http://localhost:8080/manager/text</url>  
                    <server>myserver</server>  
                    <path>/${project.build.finalName}</path>
                </configuration>
</plugin>
</plugins>
</build>


/Users/.m2/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
  <id>myserver</id>
  <username>admin</username>
  <password>admin</password>
</server>
</servers>
</settings>


To run the tomcat, which you installed(not the embedded one- and you need to run the manager portal of tomcat for auto deploy from maven

In eclipse ->

 Tomcat v7.0 Server at localhost.server  - take properties ->and click "switch location"

open it -> “server location” select “use Tomcat Installation(takes control of tomcat installation” 


now right click your spring project and run as “maven build “ -> tomcat7:redeploy will do the magic

No comments:

Post a Comment