天天看點

maven常見錯誤

常見錯誤:

一..在eclipse導入已存在工作空間的項目,出現

情況1:

scanning errors (1):

1 could not read pom.xml

就是pom.xml出現了不能解析的配置,把不能解析的配置修改過來.例如去掉

 <build>

   <finalname>testweb</finalname>

 </build>

情況2:

no marketplace entries found to handle maven-compiler-plugin:2.3.2:testcompile in eclipse.  

将eclipse内置的maven換成外部自己安裝的maven,重新開機eclipse.然後,在指令行執行mvn clean install再導入項目.

二.導入項目後出現:

project configuration is not up-to-date with pom.xml. run maven->update project or use quick fix.

在problems view的出錯提示右鍵選quick fix,再按提示确定就ok.或者,右鍵項目->maven->update project

javaserver faces 2.2 can not be installed : one or more constraints have not been satisfied.

javaserver faces 2.2 requires dynamic web module 2.5 or newer.

先改web.xmlwebapp節點:

<?xml version="1.0" encoding="utf-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"

xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

version="3.1">

然後關閉eclipse,改項目下的.settings\org.eclipse.wst.common.project.facet.core.xml.将版本改成為3.1,将成後是<installed facet="jst.web" version="3.1"/>,再啟動eclipse.最後出現上面的情況1,按上面更新下配置就ok.

三.<addmavendescriptor>false</addmavendescriptor>在eclipse無效,仍然會将pom.xml,pom.properties打包入jar.

在cli(command-line interface)運作指令,此種情況拒絕使用eclipse來執行指令(當然你測試打包入去沒影響)

maven的5種scope對于3種class是否有效:

        compile test    runtime example  

compile     y   y   y   spring-core  

test        -   y   -   junit  

provided    y   y   -   servlet-api  

runtime     -   y   y   jdbc驅動  

system      y   y   -   本地的,maven倉庫之外的類庫檔案  

左邊為第一直接依賴,上邊為第二直接依賴,則對應的依賴傳遞如下:

        compile     test        provided    runtime  

compile     compile     -       -       runtime  

test        test        -       -       test  

provided    provided    -       provided    provided  

runtime     runtime     -       -       runtime  

依賴調解兩原則:

1.路徑最近者優先

2.路徑長度相同,解析依賴聲明靠前優先

繼續閱讀