eclipse建立maven web工程

來源:互聯網
上載者:User

標籤:targe   mpi   ima   ati   代碼   編譯   上下   pom   version   

每次建maven項目,總會有問題。決定在這整理一次,避免以後浪費時間。

 

 

最後目錄為

 1.首先修改pom.xml

之前老是出現明明改了 java compiler 已maven update 一下就又變回來的情況 例如這種錯誤:

Dynamic Web Module 3.0 requires Java 1.6 or newer.
Java compiler level does not match the version of the installed Java project facet.
One or more constraints have not been satisfied.(被這個錯誤折磨好久,每次建立maven項目都要弄好久)

在加上下面代碼就好了,因為1:maven 2.1預設用jdk 1.3來編譯,maven 3 是用jdk 1.5,如果項目用的jdk 1.7也會有問題,compiler外掛程式可以指定JDK版本為1.7。 

compiler外掛程式能解決:  
<build><finalName>Maven</finalName><pluginManagement><plugins><!-- 編譯器版本 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>1.7</source><target>1.7</target></configuration></plugin></plugins></pluginManagement></build>

2.修改java compiler

 

儲存之後發現 目錄變多了

刪除了faces-config.xml,然後開啟web.xml

然後 項目右鍵--maven--update project 就發現項目不報錯了。

3.建立了jsp檔案 報錯了,是因為有包沒匯入

在pom.xml中加入下面代碼 就好了。

 <dependencies>      <!-- 匯入java ee jar 包 -->    <dependency>            <groupId>javax</groupId>            <artifactId>javaee-api</artifactId>            <version>7.0</version>        </dependency>  </dependencies>

反覆實驗了好多遍 是ok的,如果有更好的方法請告知啦。

 

eclipse建立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.