有个 Eclipse 下的 Java 项目, 虽然已经把所有的错误都调通了, 但是在工程的左下角还是有个鲜红色的叉. 检查 Problems, 可以观察到唯一一个错误如下:

Java compiler level does not match the version of the installed Java project facet. .. Unknown Faceted Project Problem (Java Version Mismatch)

这是什么意思呢? 字面意思, Java 版本不匹配. 实际意思? 不懂, 求助 google 去.

按图索骥,google中寻找错误的来源--于是很快找到了这篇博客.

从文中介绍可以知道,错误的根源是 maven 的配置有问题. maven 设置了 java 编译器和虚拟机的版本, 而当 java 版本更新后, maven 工程却没有跟上步伐, 所以这个错误就产生了.

解决方法也不困难, 寻找 pom.xml, 修改其中 java 的 version 即可.

因为linux下, 寻找同样方便

find . | grep "pom.xml"

很快就把文档找出来了.

寻找如下样子的内容

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

把高亮部分的内容修改为当前的 java 版本即可

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

7 Comments

Leniy · August 9, 2013 at 10:29

Google Chrome 28.0.1500.95 Google Chrome 28.0.1500.95 Windows 7 Windows 7

昨天运行一个新下载的程序,提示需要jre库,于是立马卸载了

    yu · August 9, 2013 at 10:41

    Google Chrome 28.0.1500.71 Google Chrome 28.0.1500.71 GNU/Linux x64 GNU/Linux x64

    jre这么讨厌,以至于见到jre就干掉?
    这几天打算在业余的时候做个本机文档全文搜索引擎,还正打算用java做的lucene来着

      Leniy · August 9, 2013 at 10:44

      Google Chrome 28.0.1500.95 Google Chrome 28.0.1500.95 Windows 7 Windows 7

      为一个小程序,再专门去安装jre不值得。

      Leniy · August 12, 2013 at 08:01

      Google Chrome 28.0.1500.95 Google Chrome 28.0.1500.95 Windows 7 Windows 7

      看看这个头像怎么样?

        yu · August 12, 2013 at 12:42

        Google Chrome 28.0.1500.71 Google Chrome 28.0.1500.71 GNU/Linux x64 GNU/Linux x64

        没有原来的顺眼…

          Leniy · August 12, 2013 at 12:42

          Google Chrome 28.0.1500.95 Google Chrome 28.0.1500.95 Windows 7 Windows 7

          上午用svg画的

            yu · August 12, 2013 at 17:38

            Google Chrome 28.0.1500.71 Google Chrome 28.0.1500.71 GNU/Linux x64 GNU/Linux x64

            我去..还整合起来了…

Leave a Reply to Leniy Cancel reply

Your email address will not be published. Required fields are marked *