简体   繁体   中英

Eclipse keeps forgetting JDK compliance, sets it to 1.6

I have a maven project in eclipse that uses some lambdas, which means I need java 8. I've already set java version in maven to 1.8. However, I have to constantly open the project's properties and set its compliance level to 1.8 because it's constantly being reset to 1.6.

I'm on Eclipse EE Luna 4.4.0, and have tried different things such as disabling per project settings, or going into the project and setting its compliance to 1.8, but both things don't work in the long term.

Usually after setting again the project compliance to 1.8 the package view shows ok, but the editor is still showing errors if I have an opened file that uses lambdas. Then I have to click on the error mark in the editor and choose the suggestion "set project compliance level to 1.8". Sometimes that works, sometimes not.

The problem is triggered specially after launching eclipse, closing and opening the same project, or when I do checkouts. The package view usually is free of errors when I do alt+f5 and update, but the editor view is often still showing errors.

My eclipse maven plugin uses the same maven scripts that I use in the command line, and I never had problems on the command line.

This is driving me crazy, because it happens at least 2x a day and doesn't have a straightforward workaround.

At the end of both my pom and parent pom file I have this:

<project>
. . .
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>  
</build>
</project>

Do you have a m2e plugin installed?

I had a similar problem before, the plugin always complain about the syntax of parent pom. I finally disabled the plugin and using mvn eclipse:eclipse to create/update the project.

In my case there is no parent pom. I resovled it by :
(1) delete the project from eclipse workspace (do not delete disk content).
(2) search "1.5" from the directory (using notepad++), found 3 occurences in .settings/org.eclipse.jdt.core.prefs , replace them with 1.8 and save.
(3) reopen the project in eclipse.

Note it does not work if you replace them in ecplise editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM