본문 바로가기

개발

[Spring] Eclipse(sts)에서 maven을 이용하여 tomcat에 배포하기

- 이클립스(sts)에서 메이븐을 이용하여 톰캣에 배포하기

환경

- sts 3.6

- maven 3.2

- tomcat7


1. Tomcat7 권한 설정

- tomcat/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. maven 권한 설정

- 사용자폴더/.m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings>

        <servers>

                <server>

                        <id>TomcatServer</id>

                        <username>id</username>

                        <password>password</password>

                </server>

        </servers>

</settings>


3. pom.xml plug-in 추가

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat7-maven-plugin</artifactId>

<version>2.2</version>

<configuration>

<url>http://localhost:8080/manager/text</url>

<server>TomcatServer</server>

<path>/path</path>

</configuration>

</plugin>


4. eclipse 프로젝트 우클릭 -> Run As -> 6.Maven Build -> 

-> Goals란에 "clean install tomcat7:redeploy" 입력 후 Run

-> 이후에는 5.Maven Build 를 눌러서 가능


..

..

[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) @ web <<<

[INFO] 

[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ web ---

[INFO] Deploying war to http:///web  

Uploading: http:///manager/text/deploy?path=%2Fweb&update=true

Uploaded: http:///manager/text/deploy?path=%2Fweb&update=true (4009 KB at 7070.5 KB/sec)


[INFO] tomcatManager status code:200, ReasonPhrase:OK

[INFO] OK - Deployed application at context path /web

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 8.336 s

[INFO] Finished at: 2014-12-06T01:15:43+09:00

[INFO] Final Memory: 21M/156M

[INFO] ------------------------------------------------------------------------



앞으로는 간단하게 이클립스(sts)에서 배포