ps:好久没写博客了,工作了人就懒了,加油加油,up,up
1 eclipse web项目目录
/web app
src
com.xx.xx
*.properties
*.xml
WebRoot
?WEB-INF
? ? ?classes
? ? ?lib
? ? ?*.xml
? ?index.jsp
2 转为maven项目,添加pom.xml
1) 创建maven web项目,把eclipse web文件拷贝到新的项目中
2) 通过在项目上右键->转为maven项目,填写信息自动创建pom.xml
3)直接在项目中创建pom.xml文件
原始pom.xml文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.syx</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
</dependencies>
<build>
<finalName>web</finalName>
</build>
</project>
3 配置class输出目录和项目jar包依赖
1)把项目的src目录配置/WebRoot/WEB-INF/classes目录下
2)把项目的lib目录jar添加到classpath
4 添加pom jetty插件和配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Maven Web</groupId>
<artifactId>Maven Web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.15</version>
<configuration>
<contextPath>/</contextPath>
<webAppSourceDirectory>WebRoot</webAppSourceDirectory>
<scanIntervalSeconds>2</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9090</stopPort>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>WebRoot/WEB-INF</directory>
<includes><include>classes</include></includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</project>