支援 Tomcat 啟動
如果偏好使用 Tomcat, 為方便在 deploy 前直接啟動 web app 檢視, 可以在 pom.xml 加入 tomcat-maven-plugin, 引用的版本最好在 properties 區塊定義, 方便更新:
  <properties>
    <tomcat.version>2.2</tomcat.version>
  </properties>
      
  <build>
    <plugins>
      <!-- Tomcat support -->
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>${tomcat.version}</version>
        <configuration>
            <path>/</path>
        </configuration>
      </plugin>
    </plugins>
  <build>
- 跟 Jetty 相反, Tomcat 預設的 web app context 是 /${project.artifactId}, 以此範例來說就是/myapp, 所以最好指定path參數. 參考 Tomcat 文件: Usage.
- 全部的 goal 參考 Plugin Documentation.
- 參數: Guide to Configuring Plug-ins. 沒有找到類似 Jetty 的 scanIntervalSeconds參數.
然後, 這樣啟動:
  mvn tomcat7:run
相關文章:
- 整合 Maven 與 Yeoman, 學習筆記(1) - node_modules
- 整合 Maven 與 Yeoman, 學習筆記(2) - 使用 mvn archetype:generate 建立 JAX-RS / Jersey 專 案
- 整合 Maven 與 Yeoman, 學習筆記(3) - jetty-maven-plugin
參考資料:
- Tomcat Usage
- Tomcat Plugin Documentation.
- Tomcat Maven Plugin Guide to Configuring Plug-ins
 
沒有留言:
張貼留言