2014-12-06 151 views
0

我在stackoverflow上找到了此解決方案。 Warning - Build path specifies execution environment J2SE-1.4Maven + Eclipse無法構建路徑

我得到了幾乎相同的問題,但不是1-4我有1-6。不幸的是我不太瞭解這個配置。這對我來說是新事物。我正在嘗試第二個解決方案來實現這個工作。我發現這個pom.xml的src中我的項目之下,它的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像plugin和Maven和JUnit這樣的單詞以紅色突出顯示。我會很感激的幫助!

回答

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項目。

+0

mvn eclipse:eclipse。我應該在控制檯中做這個嗎? – user3402584 2014-12-07 08:54:30

+0

是的,在系統控制檯中。 – mschonaker 2014-12-07 15:40:03