Solve the problem that IDEA automatically reset LanguageLevel and JavaCompiler version

When using IDEA, the default LanguageLevel and JavaCompiler of the imported Maven project are both 1.5. In the case of 1.5, even the simplest @Overrideannotation is not supported, so there may be a lot of errors in the project.

Although F4 can modify the LanguageLevel on the project, and the JavaCompiler version can be modified in the settings, but once the Maven project changes and an automatic update occurs, the modifications made here will be in vain. IDEA resets these configurations.

After Google search, I finally found a solution, refer to the following address:

http://stackoverflow.com/questions/27037657/stop-intellij-idea-to-switch-java-language-level-everytime-the-pom-is-reloaded

The solution is to specify maven-compiler-pluginthe version in pom.xml, which will affect both LanguageLevel and JavaCompiler. After modification, it will default to the version set here.

Add the following configuration:

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

 

The settings here 1.8can be modified according to personal needs.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326618458&siteId=291194637