Eclipse创建Maven web项目:





到此,并没有创建好,接下来一步步解决问题:
问题:无法创建src/main/java目录
解决:
右键项目选择【properties】

点击【OK】

问题:Cannot change version of project facet Dynamic web module to ...
解决办法:

改为你要的版本,我设为1.7

改为你要的版本,我设为1.7.0

我设为:

保存,刷新项目:

到此尚未完成,还有一个文件要修改,web.xml:

改为:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0" >
<display-name>Archetype Created Web Application</display-name>
</web-app>
到此基本完成了项目才创建。
问题:pom.xml 添加/修改 maven 依赖,但项目中 jar 并未添加/发生变化
解决办法:
右键项目,选择【Maven】->【 Update Project】

测试覆盖率:
命令:cobertura:cobertura

用浏览器打开 index.html 即可
错误:Dynamic Web Module 3.0 requires Java 1.6 or newer.
解决办法:
在 pom.xml 中 <build> 中的 <plugins> 内添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>保存,选择项目 -> 右键 -> Maven -> Update Project...
问题解决,项目中的小红叉消失了
错误:Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
解决办法:
在 pom.xml 中添加:
<!-- jsp tag library -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency> 
配置自己的数据仓库:

eclipse中使用maven插件的时候,运行run as maven build的时候报错
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
可以设一个环境变量M2_HOME指向你的maven安装目录
M2_HOME=D:Appsapache-maven-3.3.1
然后在Window->Preference->Java->Installed JREs->Edit
在Default VM arguments中设置
-Dmaven.multiModuleProjectDirectory=$M2_HOME
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
可以设一个环境变量M2_HOME指向你的maven安装目录
M2_HOME=D:Appsapache-maven-3.3.1
然后在Window->Preference->Java->Installed JREs->Edit
在Default VM arguments中设置
-Dmaven.multiModuleProjectDirectory=$M2_HOME
