LoginSignup
8
7

More than 5 years have passed since last update.

Tomcatのmanager機能を使ってmavenでデプロイする

Last updated at Posted at 2014-03-09

Tomcatのmanager機能を使ってmavenでデプロイする

デプロイ作業を簡略化して楽に開発を行う

tomcat-users.xmlを修正してroleとuserを作成する

${TOMCAT_DIR}/conf/tomcat-users.xml

私の環境だと/usr/share/tomcat/conf/tomcat-users.xml


<tomcat-users>
  <role rolename="manager-script"/>
  <user username="あなたのユーザネーム" password="あなたのパスワードをSHA-1で暗号化した物" roles="manager-script"/>
</tomcat-users>

タグは元々あるので、中を追加する

pom.xmlにtomcat7-maven-plugin追加(6なら6を追加)

          <plugin>
              <groupId>org.apache.tomcat.maven</groupId>
              <artifactId>tomcat7-maven-plugin</artifactId>
              <version>2.2</version>
              <configuration>
                  <server>適当なサーバ名</server>
                  <url>http://localhost:8080/manager/text</url>
              </configuration>
          </plugin>

server.xmlにdigest='sha-1'追加

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase" digest="sha-1"/>
      </Realm>

Catalina/localhost/manager.xml

<Context path="/manager" docBase="${catalina.home}/webapps/manager"
debug="0" privileged="true">
<Valve
className="org.apache.catalina.valves.RemoteHostValve"
allow="127.0.0.1|192.168.1.*" />
</Context>

Catalina/localhost/host-manager.xml

<Context path="/host-manager" docBase="${catalina.home}/webapps/host-manager"
  debug="0" privileged="true">
  <Valve
    className="org.apache.catalina.valves.RemoteHostValve"
    allow="127.0.0.1|192.168.1.*" />
</Context> 

設定ファイルに接続の為の設定を記載する

${.M2_HOME}/settings.xml
なければ作る

<settings>
  <servers>
    <server>
      <id>pom.xmlに書いた適当なサーバ名</id>
      <username>あなたのユーザネーム</username>
      <password>あなたのパスワード</password>
    </server>
  </servers>
</settings>

後は、mvn tomcat7:deployでOK

8
7
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
8
7