对于每个小白程序员来说,最痛苦的莫过于报错了。有的错误还好,看一眼就知道是哪里错了。但是对于有的错误,即使你翻阅无数的文档资料,一遍又一遍的修改配置,依旧遍地红花开。
为了纪念曾经遇到的报错,特第撰写此文章。也希望能对后来的小白有些帮助,
一、maven中的报错
1、错误 JavaServer Faces 2.0 requiers Dynamic Web Model 2.5 or newre;
解决方案
1.1 修改web.xml文件头 最终结果为
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
1.2 关闭eclipse 并修改项目的配置文件 .settings\org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.jsf" version="2.2"/>
<installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>
1.3 更新项目 window —preferences—maven—右键—update maven project
2、错误 Dynamic Web Modules 3.0 requiers jdk1.6 or newer
2.1解决方法 在pom.xml终配置编译插件
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
3、错误 index.jsp报错
解决方法 :配置依赖
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
4、错误 Unable to locate the Javac Compiler in: F:\jre\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java installation by setting the JAVA_HOME environment variable.
解决方法:
4.1 window —preferences—java—installed jre —execution environment—选择安装的jre
4.2 window —preferences—java—installed jre—选择安装jdk下的jre 注意和4.1区分开。
4.2 更新项目 window —preferences—maven—右键—update maven project
4.3 若还是不行 则 在eclipse的配置文件里,-vmargs之前 添加
-vm
F:\JDK\bin\javaw.exe
根据自己jkd安装的位置来
注:使用maven 3.3.9 的版本必须 配置jdk1.7及以上;
相关联的软件的安装 必须统一位数 32位 就用32位,64位就统一64位。