LoginSignup
4
5

More than 5 years have passed since last update.

Mavenを使ってtomcatにJerseyで作成したWebサービスをデプロイするメモ

Last updated at Posted at 2015-11-10

Mavenを使って既存のリモート(ローカルも可)のtomcatにJerseyで作成したWebサービスをデプロイするメモ

環境

  • tomcat7
  • Maven 3.3.1
  • Java 1.8系

tomcat側

tomcat-users.xml

<tomcat-users>
  <user username="user" password="pass" roles="manager-gui,manager-script" />
</tomcat-users>
  • Managerまわりが入っていなかった場合
    • yum install tomcat7-admin-webapps

maven側

setting.xml修正

mavenが参照する設定ファイル。Eclipseで確認する場合は設定>maven>ユーザー設定

  <settings>
    <servers>
      <server>
        <id>tomcat-test</id>
        <username>user</username>
        <password>pass</password>
      </server>
    </servers>
  </settings>

pom.xml

<!-- Tomcat plugin -->  
<plugin>  
    <groupId>org.apache.tomcat.maven</groupId>  
    <artifactId>tomcat7-maven-plugin</artifactId>  
    <version>2.2</version>  
    <configuration>  
        <server>tomcat-test</server>
        <path>/hogehoge</path>  
        <url>http://SERVER_ADDRESS:8080/manager/text</url>  
    </configuration>  
</plugin>

pom.xmlにユーザー設定等をまとめて書くやり方

<!-- Tomcat plugin -->  
<plugin>  
    <groupId>org.apache.tomcat.maven</groupId>  
    <artifactId>tomcat7-maven-plugin</artifactId>  
    <version>2.2</version>  
    <configuration>   
        <server>tomcat-test</server>
        <path>/hogehoge</path>  
        <update>true</update>  
        <url>http://SERVER_ADDRESS:8080/manager/text</url>  
        <username>user</username>  
        <password>pass</password>  
    </configuration>  
</plugin>

実行

  • goals package tomcat7:deploy
  • deployではすでに存在している場合上書きしてくれない模様なので tomcat7:redeploy にして行う

Eclipse上でのエラー

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5