2013년 8월 11일 일요일

maven에 tomcat plugin 설정하기

From : http://www.captaindebug.com/2012/03/configuring-maven-tomcat-plugin.html#.Ugg8yeYW2Kk

Copied from Captain Debug's Blog
1. Setup a Tomcat Manager Account
$TOMCAT_HOME/conf/tomcat_users.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
 <role rolename="manager-gui"/>
 <role rolename="manager-script"/>
    <user username="admin" password="password" roles="manager-gui, manager-script"/>
</tomcat-users>

2. Add the manager credentials to your settings.xml
$MAVEN_HOME/conf/settings.xml
    <server>
      <id>myserver</id>
      <username>admin</username>
      <password>password</password>
    </server>

3. Add the Maven Tomcat plug in to your POM file
Your projects/pom.xml
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.1</version>
        <configuration>
            <server>myserver</server>
            <url>http://localhost:8080/manager/text</url>
        </configuration>
    </plugin>

You can now start your server and run a Maven build using the "mvn install tomcat:deploy" command. Once installed, switch to the "tomcat:redeploy" goal.

Updated Information - by kwonjae
now there is apache tomcat plugin
So you have to write the following configuration instead of the number 3.
        <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat6-maven-plugin</artifactId>
         <version>2.1</version>
         <configuration>
           <server>myserver</server>
           <url>http://localhost:8080/manager/text</url> 
       </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat7-maven-plugin</artifactId>
         <version>2.1</version>
   </plugin>
And Some goals are not yet available with the tomcat7.
You have to write on tomcat6 and your goal have to be 'tomcat6:deploy'
From tomcat plugin, not using '/manager/html' but using '/manager/text'

refer : http://tomcat.apache.org/maven-plugin-2.1/
http://stackoverflow.com/questions/11824365/deploy-with-maven-on-tomcat7
http://stackoverflow.com/questions/5410479/tomcat-maven-plugin-403-error

댓글 없음:

댓글 쓰기