Maven + Eclipse无法构建路径

时间:2014-12-06 21:23:31

标签: java eclipse maven build path

我在stackoverflow上找到了这个解决方案。 Warning - Build path specifies execution environment J2SE-1.4

我得到了几乎相同的问题,而不是1-4我有1-6。不幸的是,我真的不明白这个配置的事情。这对我来说是新事物。我正在尝试第二个答案让这个工作。我在我的项目下的src中找到了这个pom.xml,它的xml看起来像这样:

<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>eu.jpereira.trainings.designpatterns.creational.singleton</groupId>
    <artifactId>singleton</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>singleton</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- Configure Build Process -->
    <build>
        <plugins>
            <!-- Compiler plugin to use Java 1.6 compatiblity -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <!-- Eclipse plugin to force download of source and JavaDoc jars -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <wtpversion>2.0</wtpversion>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>



    </build>
</project>

我应该添加什么,在哪里添加?我在Windows 7上使用Eclipse。我的java版本是:1.8.0.25-b18插件,Maven和JUnit等单词以红色突出显示。我很感激你的帮助!

1 个答案:

答案 0 :(得分:0)

尝试

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

然后使用mvn eclipse:eclipse重新生成Eclipse项目。