標籤:model width pid com 3.0 aging cat rar 依賴
1.建立Maven項目:File->Maven Project
選擇maven-webapp,選擇過一次後,第二次建立項目不需要重新選擇。
2.修改Project Facets
a.Java改為1.7 點擊右下角Apply
b.Dynamic Web Module 取消勾選 點擊右下角Apply
c.Dynamic Web Module Version 切換為3.0
d.Dynamic Web Module 重新勾選,此時出現Further configuration available...
點擊進入,並修改Content directory路徑為src/main/webapp
點擊右下角apply.
備忘:每一步都要點擊一次Apply 否則有可能找不到這行藍色字型哈。
3.修改Java Build Path
a.把Libraries中的JRE改為1.7
b.Source中出現missing的Remove掉,並添加src/main/java,src/main/resources,src/test/java,src/test/resources 源檔案夾
或者:
Java Resource->new Resource Folder 也一樣
如果建立過Maven Web項目,那麼這四個源檔案夾是預設已經產生了。
c.修改classes檔案位置,取消預設。同理,第二次建立項目無需重新設定
4.修改Java Complier編譯時間JDK版本,和上述的版本保持一致。均為1.7
5.修改web.xml檔案
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"></web-app>
6.修改pom檔案,添加build和依賴
<build> <finalName>你自己的項目名稱</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins></build>
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version></dependency>
<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>com.test</groupId> <artifactId>Customer</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>Customer</name> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>Customer</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build></project>
7.編譯一下,看是否配置成功/或者載入到tomcat容器中跑一跑。
Maven項目已經搭建好,準備添加代碼咯。
【Dubbo】整合Dubbo+Zookeeper+SpringMVC(二)---windows下搭建Maven項目