eclipse - m2eclipse将JDK兼容性设置为1.4

标签 eclipse maven-2 m2eclipse

使用eclipse 3.5,当我创建一个新的maven项目时,m2eclipse会自动将J2SE1.4添加到库中,并将Compiler Compliance Level添加到1.4(项目属性> Java Compiler)。
我的JRE系统库是1.6,默认的编译器遵从性级别是1.6。我什至没有安装1.4。
我可以使m2eclipse使用我的默认设置并阻止它修改项目设置吗?

最佳答案

它应遵循 maven-compiler-plugin 配置:

<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>
(即使作为mentioned in this thread,也不适用于aspect-j)
This thread让我们想起了eclipse中的m2eclipse和maven脚本之间的区别:

One thing worth to mention that this only applies to "the development mode" when m2eclipse is configuring Eclipse tools such as JDT, AJDT and WTP according to the configuration from pom.xml. This is how you normally code and debug your application, run unit tests (with Run as... / JUnit test) or run on web app server (Run as... / Server app).

However if you use Run as... / Maven build..., or create corresponding launch config from the Run/Debug menu, then you can select JVM that is used to launch Maven and all your compiler configuration will be respected in the same way it is respected in the command line.


所以:
  <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
         <verbose>true</verbose>
         <fork>true</fork>
         <executable><!-- path-to-javac --></executable>
         <compilerVersion>1.3</compilerVersion>
       </configuration>
     </plugin>
   </plugins>

m2e does not (and cannot) use external java compiler, so it will just ignore these configuration parameters. m2 only considers source/target maven-compiler-plugin parameters.

关于eclipse - m2eclipse将JDK兼容性设置为1.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3032628/

相关文章:

java - ADT 到 Android Studio 意外顶级异常

android - Eclipse 无法识别我的 Android 平板电脑

java - Android eclipse - android.jar 在 libs 文件夹和引用的库中重复

maven-2 - 用于解决 "Maven doesn' t 适用于我的问题的算法

eclipse - Maven 原型(prototype)未出现在 m2eclipse Nexus 索引器中

java - m2eclipse wtp部署带有依赖项的ejb项目

python - Eclipse 中 Python 解释器的问题

maven-2 - 使用 Nexus REST API 获取给定 groupid/artifactId 的最新 Artifact 版本

java - 将 Maven3 项目从一个 eclipse 实例导出到另一个

java - NoClassDeFoundError WSServletContextListener 和 XMLStreamBuffer