Maven2

tomcat7-maven-plugin webapps タグ

tomcat7-maven-plugin webapps タグ

ひとつの WEB APP を動作させてみる

~略~
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <server>tomcat-localhost</server>
          <path>/myapp001</path>
          <username>admin</username>
          <password>admin</password>
        </configuration>
      </plugin>
~略~

↓ >> tomcat7:run 実行

[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ myapp-001 ---
[INFO] Running war on http://localhost:8080/myapp001
[INFO] Creating Tomcat server configuration at C:\umejima\my_office\current\study\Java\jaxrs\maven-tomcat-sample2\target\tomcat
[INFO] create webapp with contextPath: /myapp001
12 18, 2017 11:47:09 午後 org.apache.coyote.AbstractProtocol init
情報: Initializing ProtocolHandler ["http-bio-8080"]

「/myapp001」context path 上で、ひとつの WEB APP が動作する。

複数の WEB APP を動作させてみる

1. 動かしたい WEB APP を探索

例:) https://github.com/visualpaper/maven-tomcat-sample

2. ローカルの maven repository にインストールする

3. groupId、artifactId、version を元に、以下のように webapps タグで囲って追加

~略~
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <server>tomcat-localhost</server>
          <path>/myapp001</path>
          <username>admin</username>
          <password>admin</password>

          <!-- WEB APPS -->
          <webapps>
            <webapp>
              <groupId>com.example.jaxrs</groupId>
              <artifactId>jaxrs-sample</artifactId>
              <version>1.1-SNAPSHOT</version>
              <type>war</type>
              <asWebapp>true</asWebapp>
            </webapp>
          </webapps>

        </configuration>
      </plugin>
~略~

↓ >> tomcat7:run 実行

[INFO] 
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ myapp-001 ---
[INFO] Running war on http://localhost:8080/myapp001
[INFO] Using existing Tomcat server configuration at C:\umejima\my_office\current\study\Java\jaxrs\maven-tomcat-sample2\target\tomcat
[INFO] create webapp with contextPath: /myapp001
[INFO] Deploying dependency wars
[INFO] Deploy warfile: C:\Users\umejima\.m2\repository\com\example\jaxrs\jaxrs-sample\1.1-SNAPSHOT\jaxrs-sample-1.1-SNAPSHOT.war to contextPath: /jaxrs-sample
12 19, 2017 12:02:31 午前 org.apache.coyote.AbstractProtocol init

「/myapp001」と「/jaxrs-sample」context path 上で、
複数の WEB APP が動作する。

myapp001.PNG

/myapp001

jaxrs-sample.PNG

/jaxrs-sample