찾다

 >  Q&A  >  본문

java - Oop! Spring Boot : Unsupported major.minor version 52.0

我根据官方向导进行spring-boot的学习,我配置好了pom.xml文件

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- Inherit defaults from Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.BUILD-SNAPSHOT</version>
    </parent>

    <!-- Add typical dependencies for a web application -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <!-- Package as an executable jar -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <!-- Add Spring repositories -->
    <!-- (you don't need this if you are using a .RELEASE version) -->
    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>
</project>

我的java版本和maven版本分别是1.7和3.3.9

然后我根据官方文档进行maven的编译以及运行,编译没有任何问题,但是当我使用命令

mvn spring-boot:run

后报错

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/SpringApplication : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at Example.main(Example.java:16)

我尝试在网上查找原因可能是JDK版本的问题,但是我的配置JDK已经是1.7了

Help!!!

伊谢尔伦伊谢尔伦2803일 전1201

모든 응답(3)나는 대답할 것이다

  • 迷茫

    迷茫2017-04-18 10:24:50

    보셔야 할 것은 컴파일된 버전입니다.

    회신하다
    0
  • ringa_lee

    ringa_lee2017-04-18 10:24:50

    안녕하세요. 저도 같은 문제에 직면했습니다. 제 jdk와 maven 버전이 귀하의 버전과 똑같습니다. 이 문제를 해결하셨나요? ? ?

    또 했는데요,
    공식 문서에 나와 있는 pom.xml의 spring-boot-starter-parent 버전을 1.4.0으로 낮추었습니다.

    으아악

    이 다음으로 변경되었습니다.

    으아악

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-18 10:24:50

    pom에서 지정된 JDK를 사용하여 컴파일

    으아악

    회신하다
    0
  • 취소회신하다