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

后端 未结 11 1451
天涯浪人
天涯浪人 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:28

    When creating a maven project in eclipse, the build path is set to JDK 1.5 regardless of settings, which is probably a bug in new project or m2e.

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

    I was facing the same issue. In pom.xml I have specified maven compiler plugin to pick 1.7 as source and target. Even then when I would import the git project in eclipse it would pick 1.5 as compile version for the project. To be noted that the eclipse has installed runtime set to JDK 1.8

    I also checked that none of the .classpath .impl or .project file is checked in git repository.

    Solution that worked for me: I simply deleted .classpath files and did a 'maven-update project'. .classpath file was regenerated and it picked up 1.7 as compile version from pom file.

    0 讨论(0)
  • 2020-11-27 12:35
    1. Right-click on your project
    2. Click Properties
    3. Click the "Java Compiler" option on the left menu
    4. Under JDK compliance section on the right, change it to "1.7"
    5. Run a Maven clean and then Maven build.
    0 讨论(0)
  • 2020-11-27 12:35

    If you are getting following type of error

    Then do the following steps-->>

    • Go to Windows. Then select Preferences, in Which select java(on the left corner).
    • In java select Installed JREs and check your JRE(if you have correctly installed jdk and defined environment variables correct then you will see the current version of the installed java here)as shown -

    (I have Java 8 installed) Check the check box if it is not checked. Click apply and close.

    Now Press Alt+Enter to go into project properties,or go via right clicking on project and select Properties.

    In Properties select Java Build Path on left corner

    Select Libraries

    And click edit(after selecting The JRE System Library...) In edit Click and select Workspace default JRE. Then click Finish

    In Order and Export Check the JRE System Library.

    Then Finally Apply and close Clean the project and then build it.

    Problem Solved..Cheers!!

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

    In order to update your project to the latest version of java available in your environment, follow these steps:

    1. Open your pom.xml file
    2. Switch your view to Effective POM tab
    3. Open Find Dialog (ctrl + F) to search for maven-compiler-plugin
    4. Copy the the following lines

    <plugin>
    	<artifactId>maven-compiler-plugin</artifactId>
    	<version>3.1</version>

    1. Click on pom.xml tab to open your project pom configuration
    2. Inside your <build> ... </build> configuration section, paste the configuration copied and modify it as...

            <plugins>
        	<plugin>
        		<artifactId>maven-compiler-plugin</artifactId>
        		<version>3.1</version>
        
        		<configuration>
        			<source>1.8</source>
        			<target>1.8</target>
        		</configuration>
        	</plugin>
        </plugins>

    1. save your configuration
    2. Right Click in your project Click on [Maven -> Update Project] and Click on OK in the displayed update dialog box.

    Done!

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

    I know this is an old topic. I had the same problem. 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 you properties:

    • Name: "maven.compiler.target" Value: "1.7"

    and

    • Name: "maven.compiler.source" Value: "1.7"

    Now do a maven update.

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