【问题标题】:Eclipse maven project JDK build pathEclipse maven项目JDK构建路径
【发布时间】:2016-06-16 04:52:30
【问题描述】:

将现有的 Maven 项目导入 Eclipse 时,从哪里驱动 JDK/JRE?例如,如下所示,在导入时,它被设置为 J2SE 1.4,但我希望它是 JDK 1.8。

如何在 Maven pom 中设置它,以便当其他开发人员获取项目时,导入时 Eclipse 将指向 JDK 1.8 而不是 1.4?

【问题讨论】:

标签: eclipse maven m2eclipse


【解决方案1】:

我的建议是从 ma​​ven-compiler-plugin 插件的配置中指定 Java 的版本。请检查以下骨架。

<?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">
    ...
    <properties>
        ...
        <java.version>1.8</java.version>
        ...
    </properties>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <verbose>true</verbose>
                    <debug>${debug}</debug>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            ... 
        </plugins>
        ...
        <resources>
            ...
        </resources>
        ...
    </build>
    ...
</project>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 2014-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 2011-11-04
    相关资源
    最近更新 更多