美文网首页
Intellij IDEA 创建Maven指定JDK版本

Intellij IDEA 创建Maven指定JDK版本

作者: 7ccc099f4608 | 来源:发表于2018-05-16 20:42 被阅读10次

解决报错 types are not supported at this language level 5

原因

一般而言,对于IDEA的Maven项目,如果不在pom.xml中指定JDK版本,则会默认使用JDK 1.5,因而不支持正则表达式等操作。

解决方案

pom.xml<project> ...</project>中加入

<profiles>
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
 </profiles>

之后,鼠标对准pom.xml右键,Maven -- Reimport,搞定~

相关文章

网友评论

      本文标题:Intellij IDEA 创建Maven指定JDK版本

      本文链接:https://www.haomeiwen.com/subject/fspmdftx.html