MyEclipse使用總結——在MyEclipse中建立Maven架構的web項目[轉]

來源:互聯網
上載者:User

標籤:des   blog   http   io   ar   os   使用   sp   java   

前面的文章我們已經在本機安裝好了maven,同時在myeclipse中配置好了maven的外掛程式。

連結如下:

Maven安裝----在Windows上安裝Maven

 

myeclipse安裝maven外掛程式

 

 

現在我們就開始在myeclipse中建立一個maven架構的web項目

建立項目

 

填寫項目名稱,一定記得勾選Add Maven support (java EE如果選取5.0報錯,則選6.0)

 

我們的maven項目就建立好了,相關基本的依賴已經在pom.xml中.項目機構如下:

可能出現的錯誤及解決方案:

遇到的問題----建立maven項目ArtifactTransferException 和Execution default-testResources of goal

 

pom.xml的內容如下:

 

[java] view plaincopy 
  1. <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">  
  2.   <modelVersion>4.0.0</modelVersion>  
  3.   <groupId>ipFilterM</groupId>  
  4.   <artifactId>ipFilterM</artifactId>  
  5.   <version>0.0.1-SNAPSHOT</version>  
  6.   <packaging>war</packaging>  
  7.   <name/>  
  8.   <description/>  
  9.   <properties>  
  10.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  11.   </properties>  
  12.   <dependencies>  
  13.     <dependency>  
  14.       <groupId>org.glassfish</groupId>  
  15.       <artifactId>bean-validator</artifactId>  
  16.       <version>3.0-JBoss-4.0.2</version>  
  17.     </dependency>  
  18.     <dependency>  
  19.       <groupId>org.glassfish</groupId>  
  20.       <artifactId>javax.annotation</artifactId>  
  21.       <version>3.0.1</version>  
  22.     </dependency>  
  23.     <dependency>  
  24.       <groupId>org.glassfish</groupId>  
  25.       <artifactId>javax.ejb</artifactId>  
  26.       <version>3.0.1</version>  
  27.     </dependency>  
  28.     <dependency>  
  29.       <groupId>org.glassfish</groupId>  
  30.       <artifactId>javax.enterprise.deploy</artifactId>  
  31.       <version>3.0.1</version>  
  32.     </dependency>  
  33.     <dependency>  
  34.       <groupId>org.glassfish</groupId>  
  35.       <artifactId>javax.jms</artifactId>  
  36.       <version>3.0.1</version>  
  37.     </dependency>  
  38.     <dependency>  
  39.       <groupId>org.glassfish</groupId>  
  40.       <artifactId>javax.management.j2ee</artifactId>  
  41.       <version>3.0.1</version>  
  42.     </dependency>  
  43.     <dependency>  
  44.       <groupId>org.eclipse.persistence</groupId>  
  45.       <artifactId>javax.persistence</artifactId>  
  46.       <version>2.0.0</version>  
  47.     </dependency>  
  48.     <dependency>  
  49.       <groupId>org.glassfish</groupId>  
  50.       <artifactId>javax.resource</artifactId>  
  51.       <version>3.0.1</version>  
  52.     </dependency>  
  53.     <dependency>  
  54.       <groupId>org.glassfish</groupId>  
  55.       <artifactId>javax.security.auth.message</artifactId>  
  56.       <version>3.0.1</version>  
  57.     </dependency>  
  58.     <dependency>  
  59.       <groupId>org.glassfish</groupId>  
  60.       <artifactId>javax.security.jacc</artifactId>  
  61.       <version>3.0.1</version>  
  62.     </dependency>  
  63.     <dependency>  
  64.       <groupId>org.glassfish</groupId>  
  65.       <artifactId>javax.servlet</artifactId>  
  66.       <version>3.0.1</version>  
  67.     </dependency>  
  68.     <dependency>  
  69.       <groupId>org.glassfish</groupId>  
  70.       <artifactId>javax.servlet.jsp</artifactId>  
  71.       <version>3.0.1</version>  
  72.     </dependency>  
  73.     <dependency>  
  74.       <groupId>org.glassfish</groupId>  
  75.       <artifactId>javax.servlet.jsp.jstl</artifactId>  
  76.       <version>3.0.1</version>  
  77.     </dependency>  
  78.     <dependency>  
  79.       <groupId>org.glassfish</groupId>  
  80.       <artifactId>javax.transaction</artifactId>  
  81.       <version>3.0.1</version>  
  82.     </dependency>  
  83.     <dependency>  
  84.       <groupId>javax.xml.bind</groupId>  
  85.       <artifactId>jaxb-api-osgi</artifactId>  
  86.       <version>2.2.1</version>  
  87.     </dependency>  
  88.     <dependency>  
  89.       <groupId>javax.ws.rs</groupId>  
  90.       <artifactId>jsr311-api</artifactId>  
  91.       <version>1.1.1</version>  
  92.     </dependency>  
  93.     <dependency>  
  94.       <groupId>org.glassfish.web</groupId>  
  95.       <artifactId>jstl-impl</artifactId>  
  96.       <version>1.2</version>  
  97.     </dependency>  
  98.     <dependency>  
  99.       <groupId>javax.mail</groupId>  
  100.       <artifactId>mail</artifactId>  
  101.       <version>1.4.3</version>  
  102.     </dependency>  
  103.     <dependency>  
  104.       <groupId>javax.xml</groupId>  
  105.       <artifactId>webservices-api-osgi</artifactId>  
  106.       <version>2.0.1</version>  
  107.     </dependency>  
  108.     <dependency>  
  109.       <groupId>org.jboss.weld</groupId>  
  110.       <artifactId>weld-osgi-bundle</artifactId>  
  111.       <version>1.0.1-SP3</version>  
  112.     </dependency>  
  113.   </dependencies>  
  114.   <build>  
  115.     <plugins>  
  116.       <plugin>  
  117.         <artifactId>maven-war-plugin</artifactId>  
  118.       </plugin>  
  119.       <plugin>  
  120.         <artifactId>maven-compiler-plugin</artifactId>  
  121.         <configuration>  
  122.           <source>1.6</source>  
  123.           <target>1.6</target>  
  124.         </configuration>  
  125.       </plugin>  
  126.     </plugins>  
  127.   </build>  
  128. </project>  



 

到這一步我們的web項目就建好了, 不過還有一步重要的步驟,就是把相關依賴的包下載到本地倉庫。

 

對著項目右鍵: run as  ----> maven install

 

在控制台就可以看到 依賴包開始自動從 maven的中央倉庫開始下載

 

下載完後我們可以看到build success

 

 

到此為止,我們的maven架構的web項目就建立好了。

 

MyEclipse使用總結——在MyEclipse中建立Maven架構的web項目[轉]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.