您的位置:首页 > 其它

maven常见错误

2015-11-02 09:42 260 查看

转自:https://www.geek-share.com/detail/2598088280.html

常见错误:

一..在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再导入项目.


二.导入项目后出现:

情况1:

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

情况2:

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是否有效:

[html]view plaincopy
  1. compiletestruntimeexample
  2. compileYYYspring-core
  3. test-Y-junit
  4. providedYY-servlet-api
  5. runtime-YYjdbc驱动
  6. systemYY-本地的,maven仓库之外的类库文件


左边为第一直接依赖,上边为第二直接依赖,则对应的依赖传递如下:

[html]view plaincopy
  1. compiletestprovidedruntime
  2. compilecompile--runtime
  3. testtest--test
  4. providedprovided-providedprovided
  5. runtimeruntime--runtime



依赖调解两原则:

1.路径最近者优先

2.路径长度相同,解析依赖声明靠前优先


阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: