Maven “build path specifies execution environment J2SE-1.5”, even though I changed it to 1.7

后端 未结 11 1452
天涯浪人
天涯浪人 2020-11-27 12:00

In Eclipse Juno, I installed the latest m2e plugin (1.2.20120903-1050). In preferences, I have added jdk1.7.0_11 in Java -> Installed JREs -> Add, and then specified the lo

相关标签:
11条回答
  • 2020-11-27 12:46

    For imported maven project and JDK 1.7 do the following:

    1. Delete project from Eclipse (keep files)
    2. Delete .settings directory, .project and .classpath files inside your project directory.
    3. Modify your pom.xml file, add following properties (make sure following settings are not overridden by explicit maven-compiler-plugin definition in your POM)

      <properties>
          <maven.compiler.source>1.7</maven.compiler.source>
          <maven.compiler.target>1.7</maven.compiler.target>
      </properties>
      
    4. Import updated project into Eclipse.

    0 讨论(0)
  • 2020-11-27 12:49

    I tested all the answers about this topic. And nothing worked here… but I found another solution.

    Go to pom -> overview and add these to your properties:

    Name: “maven.compiler.target” Value: “1.8”

    and

    Name: “maven.compiler.source” Value: “1.8”

    Now do a maven update.

    0 讨论(0)
  • 2020-11-27 12:54

    All of the answers above may work for the time being but whenever you run maven on the command line or Maven → Update project… the JDK will be reset, this was also the question as I understand it.

    To fix this for good add the following code to your pom file. Remember to do a Maven → Update project… afterwards or mvn clean compile at the command line.

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
    
        </pluginManagement>
    </build>
    
    0 讨论(0)
  • 2020-11-27 12:55

    I'm using Juno 4.2 with latest spring, maven plugin and JDK1.6.0_25.

    I faced same issue and here is my fix that make default after each Eclipse restart:

    1. List item
    2. Right-click on the maven project
    3. Java Build Path
    4. Libraries tab
    5. Select current wrong JRE item
    6. Click Edit
    7. Select the last option (Workspace default JRE (jdk1.6.0_25)
    0 讨论(0)
  • 2020-11-27 12:55

    I got an error in Eclipse Mars version as "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.

    To resolve this issue, please do the following steps, "Right click on Project Choose Build path Choose Configure Build path Choose Libraries tab Select JRE System Library and click on Edit button Choose workspace default JRE and Finish

    Problem will be resolved.

    0 讨论(0)
提交回复
热议问题