標籤: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工程