How to force Eclipse m2e plugin to use jdk for a project

笑着哭i 提交于 2019-12-18 13:27:49

问题


I'm using Maven with 'Eclipse Kepler JavaEE'. I have something like this in 'maven-compiler-plugin' :

<configuration>
    <source>1.7</source>
    <target>1.7</target>
</configuration>

Each time I'm changing somethin in 'pom.xml', eclipse forces me to perform 'Maven -> Update Project' and than project settings are changed to use JRE instead JDK and some maven builds are stopping to work.

The only solution I found to solve it is to set How I can set eclipse/m2e to use JDK is to define a path in maven-compiler-plugin. It is not good solution, since it is working only for my computer will fail for other.

I think there are some maven or m2e definitions saying "use jdk and not jre".


回答1:


In Eclipse, open Window | Preferences | Java | Installed JREs, make sure there's a JDK (and not just a JRE) for Java 1.7, then go to the submenu Execution Environments and mark this JDK as compatible with JavaSE-1.7.

After that, Maven | Update Project should work as desired.




回答2:


First MVN_HOME has to be setup and then the JDK as to browsed instead of JRE

Window--> Preferences--> Java-->Installed JREs

and select JDK (e.g. : jdk1.7 or jdk1.8)

the do mvn install it will work



来源:https://stackoverflow.com/questions/25592290/how-to-force-eclipse-m2e-plugin-to-use-jdk-for-a-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!