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官網
<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> <!-- 需要生成的目標class文件的編譯版本 -->
<!-- 一般而言,target與source是保持一致的结胀,但是跑杭,有時候為了讓程序能在其他版本的jdk中運行(對于低版本目標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官網
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>
<!-- 目標路徑-->
<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.
[未完茶行。]