springboot + jdk6:Unsupported major.minor version 51.0

官方文档:
How to use Java 6

If you want to use Spring Boot with Java 6 there are a small number of configuration changes that you will have to make. The exact changes depend on your application’s functionality.

Embedded servlet container compatibility

If you are using one of Boot’s embedded Servlet containers you will have to use a Java 6-compatible container. Both Tomcat 7 and Jetty 8 are Java 6 compatible. See Use Tomcat 7 and Use Jetty 8 for details.

JTA API compatibility

While the Java Transaction API itself doesn’t require Java 7 the official API jar contains classes that have been built to require Java 7. If you are using JTA then you will need to replace the official JTA 1.2 API jar with one that has been built to work on Java 6. To do so, exclude any transitive dependencies on javax.transaction:javax.transaction-api and replace them with a dependency on org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final

1、错误:java.lang.UnsupportedClassVersionError: javax/annotation/ManagedBean : Unsupported major.minor version 51.0

解决:
若你的项目直接或间接继承spring-boot-dependencies(比如spring-boot-starter-parent)进行构建,那你只需进行第三步即可!

若你使用import,将spring-boot-dependencies添加到自己的dependencyManagement片段–如下:

 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-dependenciesartifactId>
                <version>${spring-boot.version}version>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>
    dependencyManagement>

则可以:
1、进入 spring-boot-dependencies-1.3.6.RELEASE.pom文件
2、搜索“tomcat.version”,将所有该版本依赖项拷贝到你的项目pom文件中。
3、添加 项: 7.0.52

2、错误:java.lang.UnsupportedClassVersionError: javax/transaction/SystemException : Unsupported major.minor version 51.0

解决:

<dependency>
     <groupId>org.springframework.bootgroupId>
      <artifactId>spring-boot-starter-data-jpaartifactId>
      <exclusions>
          <exclusion>
              <groupId>javax.transactiongroupId>
              <artifactId>javax.transaction-apiartifactId>
          exclusion>
      exclusions>
dependency>

<dependency>
    <groupId>org.jboss.spec.javax.transactiongroupId>
    <artifactId>jboss-transaction-api_1.2_specartifactId>
    <version>1.0.0.Finalversion>
dependency>

你可能感兴趣的:(SpringBoot)