maven中配置插件

maven中自定義插件。

1.maven pom.xml 中配置jetty插件

<build>
      <!-- will be final-app-name.war -->
      <finalName>final-app-name</finalName> 
      <plugins>
          <plugin>
              <!-- a plugin must have minimum config of groupId, artifactId, version -->
              <groupId>org.mortbay.jetty</groupId>
              <artifactId>maven-jetty-plugin</artifactId>
              <version>6.1.7</version>
              <configuration>
                  <!-- interval of jetty scanning the project -->
                  <scanIntervalSeconds>10</scanIntervalSeconds>
                  <!-- contextpath of web. Users can visit by http://hostname:port/test/  -->
                  <contextPath>/test</contextPath>
                  <connectors>
                      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                          <port>8080</port>
                          <maxIdleTime>60000</maxIdleTime>
                      </connector>
                  </connectors>
              </configuration>
          </plugin>
      </plugins>
</build>

2.pom.xml 中配置maven-compiler-plugin插件

The Compiler Plugin is used to compile the sources of your project.
Default source and target jdk is 1.5, independently the jdk you run.
參考鏈接-Maven官網(wǎng)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.6</source> <!-- 源代碼使用的開發(fā)版本 -->
        <target>1.6</target> <!-- 需要生成的目標(biāo)class文件的編譯版本 -->
        <!-- 一般而言,target與source是保持一致的,但是,有時候為了讓程序能在其他版本的jdk中運行(對于低版本目標(biāo)jdk,源代碼中需要沒有使用低版本jdk中不支持的語法),會存在target不同于source的情況 -->
    
        <!-- 這下面的是可選項 -->
        <meminitial>128m</meminitial>
        <maxmem>512m</maxmem>
        <fork>true</fork> <!-- fork is enable,用于明確表示編譯版本配置的可用 --> 
        <compilerVersion>1.3</compilerVersion>        
    </configuration>
</plugin>

The same effect with:

<!-- pom.xml -->
<project>
  [...]
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  [...]
</project>

參考鏈接-Maven官網(wǎng)
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html


3.pom.xml中配置maven-war-plugin插件,用來打war包。

 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
            <webResources>
                <resource>
                    <!-- 元配置文件的目錄,相對于pom.xml文件的路徑。-->
                    <!--在打包的時候,將directory中的文件全部搬運到targetPath。 -->
                    <directory>src/main/resources</directory>
                    <!-- 目標(biāo)路徑-->
                    <targetPath>WEB-INF</targetPath>
                </resource>
            </webRespurces>
            <!--/sample/servlet/container/deploy/directory-->
           <webappDirectory>
                <!-- 自定義的 ${project.build.directory}/${project.artifactId}-->
                /sample/servlet/container/deploy/directory
           </webappDirectory>
        </configuration>
      </plugin>

Note:
The default resource directory for all Maven projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the WAR.

參考鏈接-Maven官網(wǎng)

[未完。]

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 所有項目的構(gòu)建都是有生命周期的,這個生命周期包括:項目清理、初始化、編譯、測試、打包、集成測試、驗證、部署、站點生...
    zlcook閱讀 3,019評論 0 21
  • 1.編寫POM Maven項目的核心文件是pom.xml,POM(Project Objcet Model)項目對...
    zlcook閱讀 6,014評論 7 26
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,711評論 19 139
  • Spring Boot 參考指南 介紹 轉(zhuǎn)載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 47,290評論 6 342
  • 當(dāng)前,JVM生態(tài)圈主要的三大構(gòu)建工具: Apache Ant(帶著Ivy) Maven Gradle 對于剛開始接...
    清楓_小天閱讀 5,996評論 1 13

友情鏈接更多精彩內(nèi)容