1、安装maven插件: http://download.eclipse.org/technology/m2e/releases
2、使用import-->maven-->existing maven project导入已从svn上checkout下来的maven项目
3、在本地maven库安装目录中放入setting.xml,示例代码如下:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
5
6 <pluginGroups/>
7 <proxies/>
8 <servers>
9 <server>
10 <id>web-releases</id>
11 <username>admin</username>
12 <password>admin123</password>
13 </server>
14 <server>
15 <id>web-snapshots</id>
16 <username>admin</username>
17 <password>admin123</password>
18 </server>
19 </servers>
20
21 <mirrors>
22
23 <mirror>
24 <id>mid</id>
25 <mirrorOf>*</mirrorOf>
26 <url>http://192.168.16.6:8081/nexus/content/groups/public/</url>
27 </mirror>
28 </mirrors>
29
30 <profiles>
31 <profile>
32 <id>nexus</id>
33 <repositories>
34 <repository>
35 <id>nexus</id>
36 <name>local private nexus</name>
37 <url>http://192.168.16.6:8081/nexus/content/repositories/releases/</url>
38 <releases><enabled>true</enabled></releases>
39 <snapshots><enabled>true</enabled></snapshots>
40 </repository>
41 <repository>
42 <id>nexus</id>
43 <name>local private nexus</name>
44 <url>http://192.168.16.6:8081/nexus/content/repositories/snapshots/</url>
45 <releases><enabled>true</enabled></releases>
46 <snapshots><enabled>true</enabled></snapshots>
47 </repository>
48 </repositories>
49 <pluginRepositories>
50 <pluginRepository>
51 <id>nexus</id>
52 <name>local private nexus</name>
53 <url>http://192.168.16.6:8081/nexus/content/groups/public</url>
54 <releases><enabled>true</enabled></releases>
55 <snapshots><enabled>false</enabled></snapshots>
56 </pluginRepository>
57 </pluginRepositories>
58 </profile>
59 </profiles>
60
61 <activeProfiles>
62 <activeProfile>nexus</activeProfile>
63 </activeProfiles>
64
65 </settings>
4、运行maven-->update dependency将依赖插件及Jar包等相关文件down到本地Maven库中
5、新建一个tomcat 6.0 server,在eclipse中生成的servers工程中修改以下配置文件属性:
6、在catalina.properties中增加key-value配置,在应用项目相关配置文件中就可直接通过${key}的方式获取value
7、修改server.xml,增加如下示例JNDI资源配置(http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html):
1 <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
2 <Context path="/internal" docBase="E:/svn_working/cd/internal/trunk/target/apps-internal" debug="0" reloadable="true" crossContext="true" >
3 <Resource name="jdbc/internalds" auth="Container" type="javax.sql.DataSource"
4 maxActive="100" maxIdle="30" maxWait="10000"
5 username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
6 url="jdbc:mysql://localhost:3306/customer"/>
7 </Context>
8、修改web.xml,增加:
1 <description>MySQL Test App</description>
2 <resource-ref>
3 <description>DB Connection</description>
4 <res-ref-name>jdbc/internalds</res-ref-name>
5 <res-type>javax.sql.DataSource</res-type>
6 <res-auth>Container</res-auth>
7 </resource-ref>
9、项目run as --> maven clean, run as--> maven build(goals:package, skip test=true)