Maven没有指定JavaJDK吗?

Maven没有指定JavaJDK吗?,java,maven,intellij-idea,Java,Maven,Intellij Idea,我试图指定在Maven/IntellijIDEA中使用哪个JavaJDK版本。我想使用JDK 7,但源代码似乎总是用JDK 8编译。我做了很多事情,这是IntelliJ IDEA项目结构设置的截图: 这是我的pom.xml。如您所见,我正在使用属性和maven编译器插件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=

我试图指定在Maven/IntellijIDEA中使用哪个JavaJDK版本。我想使用JDK 7,但源代码似乎总是用JDK 8编译。我做了很多事情,这是IntelliJ IDEA项目结构设置的截图:

这是我的pom.xml。如您所见,我正在使用属性和maven编译器插件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-          4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me.staticjava</groupId>
<artifactId>VillagerMerchants</artifactId>
<version>1.0-SNAPSHOT</version>

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

<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>

<repositories>
    <repository>
        <id>spigot-repo</id>
        <url>http://repo.md-5.net/content/groups/public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot-api</artifactId>
        <version>1.7.9-R0.3-SNAPSHOT</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>org.bukkit</groupId>
        <artifactId>craftbukkit</artifactId>
        <version>1.7.9-R0.3-SNAPSHOT</version>
    </dependency>
</dependencies>
我不知道为什么,但代码总是编译在1.8

有什么帮助吗

谢谢, ~StaticJava

您需要进入设置->项目设置->Maven->Runner并检查JRE设置

我的设置是使用JDK1.7项目,但听起来你的设置是不同的

顺便说一下,我想您应该知道POM1.7中的语言级别与您编译时使用的实际JDK不同。例如,您可以很好地使用JDK 1.8,但编译到语言级别java 7…:


祝你好运。

在控制台上运行mvn-version时,你会得到什么@user432Did您是否使用intellij中的java_home指定不同的jdk?检查并在ide中运行相同的命令。@Hannes As run in IntelliJ:我猜工具没有按预期工作。如果您想信任源代码,可以查看源代码并亲自查看。