maven 插件总结

Eclipse调试原理可以参考
http://www.ibm.com/developerworks/cn/opensource/os-eclipse-javadebug/

1 常用配置

<properties>
<!-- 主要依赖库的版本定义 -->
<jetty.version>6.1.26</jetty.version>
<jdk.version>1.6</jdk.version>
<!-- Plugin的属性定义 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- j2ee web spec -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>

<!-- test begin -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>

<!-- jetty -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-jetty</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- compiler插件, 设定JDK版本 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

<!-- war插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>

<!-- resource插件, 设定编码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

<!-- jar插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>

<!-- eclipse插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<wtpversion>2.0</wtpversion>
<!-- 额外的eclipse外观 -->
<!-- <additionalProjectFacets> </additionalProjectFacets> -->
<!-- 不打包.svn文件 -->
<sourceExcludes>
<sourceExclude>**/.svn/</sourceExclude>
</sourceExcludes>
<downloadSources>true</downloadSources>
<!-- <downloadJavadocs>true</downloadJavadocs> -->
</configuration>
</plugin>

<!-- jetty插件 -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<!-- 项目直接放在根目录下运行 -->
<contextPath>/</contextPath>
<connectors>
<!-- 使用NIO提升性能 -->
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<!-- 配置监听端口 -->
<port>8080</port>
</connector>
</connectors>
<reload>manual</reload>
</configuration>
</plugin>
</plugins>
</build>


2 常用的 maven build
eclipse2maven:

eclipse:clean


jettyrun

jetty:run -Dmaven.test.skip=true


mvn2eclipse

eclipse:eclipse -Dwtpversion=2.0


3 常用的脚本
在项目根目录下建立bin文件夹
jetty.bat

@echo off
echo [INFO] Use maven jetty-plugin run the project.

cd %~dp0
cd ..

set MAVEN_OPTS=%MAVEN_OPTS%
call mvn jetty:run -Dmaven.test.skip=true

cd bin
pause


4 在ECLIPSE中调试JETTY
[quote]
Step 1
Go to the Run/External Tools/External Tools ..." menu item on the "Run" menu bar. Select "Program" and click the "New" button. On the "Main" tab, fill in the "Location:" as the full path to your "mvn" executable. For the "Working Directory:" select the workspace that matches your webapp. For "Arguments:" add jetty:run.

Move to the "Environment" tab and click the "New" button to add a new variable named MAVEN_OPTS with the value:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y

If you supply suspend=n instead of suspend=y you can start immediately without running the debugger and launch the debugger at anytime you really wish to debug.

Step 2

Then, pull up the "Run/Debug/Debug ..." menu item and select "Remote Java Application" and click the "New" button. Fill in the dialog by selecting your webapp project for the "Project:" field, and ensure you are using the same port number as you specified in the address= property above.

Now all you need to do is to Run/External Tools and select the name of the maven tool setup you created in step 1 to start the plugin and then Run/Debug and select the name of the debug setup you setup in step2.

From instructions provided by Rolf Strijdhorst on the Maven mailing list

Stopping Jetty

In order to stop the jetty server the "Allow termination of remote VM" should be checked in debug dialog in Step 2. When you have the jetty server running and the debugger connected you can switch to the debug perspective. In the debug view, right click on the Java HotSpot(TM) Client VM[localhost:4000] and chose terminate. This will stop the debugger and the jetty server.
[/quote]

第一步:RUN --》倒数第二个TOOLS里添加--》PROGRAM里--》new -->main里写
LOCATION:E:\apache-maven-3.0\bin\mvn.bat
WROKDING DIRECTORY选项目目录${workspace_loc:/jsp}
Arguments:jetty:run
ENVIRONMENT里NEW
NAME:MAVEN_OPTS
VALUE:-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

第二步:RUN-->DEBUG CONFIGRATION--》REMOTE JAVA APPLICATION里
PROJECT选要调试的项目,CONNECTION TYPE:选第一个
HOST:localhost
port:8000

先运行第一步再运行第二步

5 把JAR包COPY到LIB包下发布到TOMCAT上

mvn dependency:copy-dependencies


JAR包会都被COPY到target目录下WEB-INF下的LIB下
然后把整个LIB COPY到SRC/MAIN/WEBAPP/WEB-INF/LIB下
没有LIB目录就自己创建一个
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值