为什么 Maven 会更改 Eclipse 项目首选项?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13256654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:21:00  来源:igfitidea点击:

Why Maven changes Eclipse project preferences?

eclipsemavenconfigurationm2eclipse

提问by ilazgo

First of all, I'm using Ubuntu 12.04, Eclipse Juno with embebbed maven 3.0.4 (m2eclipse) and I have to work in a legacy project which I got from a SVN repositroy.

首先,我使用的是 Ubuntu 12.04、Eclipse Juno 和嵌入式 maven 3.0.4 (m2eclipse),我必须在我从 SVN 存储库中获得的遗留项目中工作。

I'm stuck in a sort of configuration problem with Maven and Eclipse.

我遇到了 Maven 和 Eclipse 的配置问题。

At the first time I did a Maven > Update project and I got an "Unknown Error" of "Maven Java EE Configuration Problem" type. I checked my project's properties and I've realized that java compliance level is set to 1.5 but I have 1.6 JRE activated. Well, I've changed to 1.6 version (in Java Facet too), but when I do a Maven > Update project, my project's properties are restored to default (a.k.a. 1.5 version), and the Unknown error persists.

第一次我做了一个 Maven > Update 项目,我得到了一个“Maven Java EE 配置问题”类型的“未知错误”。我检查了我的项目的属性,我意识到 Java 合规性级别设置为 1.5,但我激活了 1.6 JRE。好吧,我已更改为 1.6 版本(也在 Java Facet 中),但是当我执行 Maven > Update 项目时,我的项目属性恢复为默认值(又名 1.5 版本),并且未知错误仍然存​​在。

My pom.xml file seems to be ok, and I also try to update project with an empty pom.xml (just with modelVersion, groupId, artifactId, version, name and url tags) and I always get the same error.

我的 pom.xml 文件似乎没问题,我还尝试使用空 pom.xml 更新项目(仅使用 modelVersion、groupId、artifactId、version、name 和 url 标签),但我总是遇到相同的错误。

I'm really stuck. Someone has a clue?

我真的被困住了。有人有线索吗?

回答by maximdim

Try specifying JDK version in pom.xml:

尝试在 pom.xml 中指定 JDK 版本:

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

and then do 'Update Project Configuration'

然后执行“更新项目配置”