jdk version of the IDEA-Maven project settings

In Intellij IDEA, we need to set the jdk version of Java Compiler Settings and Project Structure in Language Level in their own version currently in use, otherwise we will often prompt a syntax error caused by an incorrect version of jdk. In Maven project, jdk configuration also places some additional needs attention.

Such as configured jdk1.8:

JavaCompiler

LanguageLevel

But in the Maven project, set the Java Compiler and Language level will be automatically changed back to jdk version pom.xml file or set the default jdk1.5 version. So we need to modify the version of jdk configuration or add your own in the pom.xml configuration file:

<!-- 这里一般有 maven 的默认配置,修改即可 -->
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
 </properties>

or:

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

Note: If you have configured properties and build inside, then properties will overwrite build inside the configuration, that is subject to the properties inside the configuration.

PS: If you think something is wrong article, where poorly written, or have any suggestions, please advice.

Welcome to your thumbs, collection and comment!
(Finish)

Guess you like

Origin www.cnblogs.com/deecyn/p/11442119.html