Springboot 1.5.6 升级到 2.1.8

文章目录

  • Springboot 1.5.6 升级到 2.1.8
        • 1、findOne 方法不存在
        • 2、RedisCache 报错
        • 3、WebMvcConfigurerAdapter 已经过时
        • 4、SpringBootServletInitializer 类不存在
        • 5、JPA save 方法类型不匹配
        • 6、JPA delete方法类型不匹配
        • 7、JPA 的repo 接口中定义的 findById 方法报错
        • 8、配置文件中 context-path 报错
        • 9、启动报错
          • 1、传送门
          • 2、表格表示
          • 3、包依赖的差异
        • 10、启动失败
        • 11、JPA 找不到表 hibernate_sequence

Springboot 1.5.6 升级到 2.1.8


1、findOne 方法不存在

someRepo.findOne(ID id);

需要改为

someRepo.getOne(ID id);

2、RedisCache 报错

应该改为如下形式,本代码仅为简单示例,没有详细配置参数

@Configuration
@EnableCaching
public class CacheConfiguration {

  @Bean
  CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
    RedisCacheConfiguration configuration =
        RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(5));

    return RedisCacheManager.builder(
            RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory))
        .cacheDefaults(configuration)
        .build();
  }
}

3、WebMvcConfigurerAdapter 已经过时

请使用WebMvcConfigurationSupport 代替该类

4、SpringBootServletInitializer 类不存在

该类的位置有变动
请引入该类的新位置,位于包import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

5、JPA save 方法类型不匹配

save 方法使用迭代器参数时,请改为saveAll 方法

6、JPA delete方法类型不匹配

改为deletedById(ID id)方法替代 delete(ID id)

delete 方法使用迭代器参数时,请改为deleteAll 方法

7、JPA 的repo 接口中定义的 findById 方法报错

1、删除该方法,并使用getOne 方法代替

2、或者删除该方法,使用含有Optional 封装的值,并修改代码形式

8、配置文件中 context-path 报错

因为参数位置已经变更,需要改为server.servlet.context-path

9、启动报错

报错如下

11:47:03.525 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/deploy.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/ext/zipfs.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/javaws.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/jfxswt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/management-agent.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/plugin.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_191/jre/lib/rt.jar, file:/E:/idea_project_path/api-cyc-mini/target/classes/, file:/C:/Users/A-PC/.m2/repository/com/github/pagehelper/pagehelper-spring-boot-starter/1.2.5/pagehelper-spring-boot-starter-1.2.5.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.8.RELEASE/spring-boot-starter-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot/2.1.8.RELEASE/spring-boot-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.8.RELEASE/spring-boot-autoconfigure-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar, file:/C:/Users/A-PC/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar, file:/C:/Users/A-PC/.m2/repository/com/github/pagehelper/pagehelper-spring-boot-autoconfigure/1.2.5/pagehelper-spring-boot-autoconfigure-1.2.5.jar, file:/C:/Users/A-PC/.m2/repository/com/github/pagehelper/pagehelper/5.1.4/pagehelper-5.1.4.jar, file:/C:/Users/A-PC/.m2/repository/com/github/jsqlparser/jsqlparser/1.0/jsqlparser-1.0.jar, file:/C:/Users/A-PC/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-starter/1.3.2/mybatis-spring-boot-starter-1.3.2.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.1.8.RELEASE/spring-boot-starter-jdbc-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-jdbc/5.1.9.RELEASE/spring-jdbc-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/1.3.2/mybatis-spring-boot-autoconfigure-1.3.2.jar, file:/C:/Users/A-PC/.m2/repository/org/mybatis/mybatis/3.4.6/mybatis-3.4.6.jar, file:/C:/Users/A-PC/.m2/repository/org/mybatis/mybatis-spring/1.3.2/mybatis-spring-1.3.2.jar, file:/C:/Users/A-PC/.m2/repository/redis/clients/jedis/2.9.3/jedis-2.9.3.jar, file:/C:/Users/A-PC/.m2/repository/org/slf4j/slf4j-api/1.7.28/slf4j-api-1.7.28.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/commons/commons-pool2/2.6.2/commons-pool2-2.6.2.jar, file:/C:/Users/A-PC/.m2/repository/com/aliyun/oss/aliyun-sdk-oss/2.8.2/aliyun-sdk-oss-2.8.2.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/httpcomponents/httpclient/4.5.9/httpclient-4.5.9.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/httpcomponents/httpcore/4.4.12/httpcore-4.4.12.jar, file:/C:/Users/A-PC/.m2/repository/org/jdom/jdom/1.1/jdom-1.1.jar, file:/C:/Users/A-PC/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar, file:/C:/Users/A-PC/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, file:/C:/Users/A-PC/.m2/repository/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar, file:/C:/Users/A-PC/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.58/bcprov-jdk15on-1.58.jar, file:/C:/Users/A-PC/.m2/repository/com/alibaba/fastjson/1.2.7/fastjson-1.2.7.jar, file:/C:/Users/A-PC/.m2/repository/org/json/json/20160810/json-20160810.jar, file:/E:/idea_project_path/api-cyc-mini/src/main/resources/weixin4j-1.0.jar, file:/C:/Users/A-PC/.m2/repository/javax/servlet/jsp/jsp-api/2.2.1-b03/jsp-api-2.2.1-b03.jar, file:/C:/Users/A-PC/.m2/repository/org/projectlombok/lombok/1.16.16/lombok-1.16.16.jar, file:/C:/Users/A-PC/.m2/repository/org/xkk/utils/1.4-Release/utils-1.4-Release-Release.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/poi/poi/3.15/poi-3.15.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/poi/poi-ooxml/3.15/poi-ooxml-3.15.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/poi/poi-ooxml-schemas/3.15/poi-ooxml-schemas-3.15.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar, file:/C:/Users/A-PC/.m2/repository/com/github/virtuald/curvesapi/1.04/curvesapi-1.04.jar, file:/C:/Users/A-PC/.m2/repository/javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar, file:/C:/Users/A-PC/.m2/repository/cglib/cglib/3.2.5/cglib-3.2.5.jar, file:/C:/Users/A-PC/.m2/repository/org/ow2/asm/asm/6.0_ALPHA/asm-6.0_ALPHA.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/ant/ant/1.9.6/ant-1.9.6.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/ant/ant-launcher/1.9.6/ant-launcher-1.9.6.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.9/jackson-core-2.9.9.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.9.3/jackson-databind-2.9.9.3.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar, file:/C:/Users/A-PC/.m2/repository/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar, file:/C:/Users/A-PC/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar, file:/C:/Users/A-PC/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/C:/Users/A-PC/.m2/repository/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar, file:/C:/Users/A-PC/.m2/repository/commons-fileupload/commons-fileupload/1.3.2/commons-fileupload-1.3.2.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/httpcomponents/httpmime/4.5.1/httpmime-4.5.1.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-eureka/1.3.5.RELEASE/spring-cloud-starter-eureka-1.3.5.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter/1.2.4.RELEASE/spring-cloud-starter-1.2.4.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-context/1.2.4.RELEASE/spring-cloud-context-1.2.4.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/security/spring-security-crypto/5.1.6.RELEASE/spring-security-crypto-5.1.6.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-commons/1.2.4.RELEASE/spring-cloud-commons-1.2.4.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/security/spring-security-rsa/1.0.3.RELEASE/spring-security-rsa-1.0.3.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.55/bcpkix-jdk15on-1.55.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-netflix-core/1.3.5.RELEASE/spring-cloud-netflix-core-1.3.5.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-netflix-eureka-client/1.3.5.RELEASE/spring-cloud-netflix-eureka-client-1.3.5.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/eureka/eureka-client/1.6.2/eureka-client-1.6.2.jar, file:/C:/Users/A-PC/.m2/repository/org/codehaus/jettison/jettison/1.3.7/jettison-1.3.7.jar, file:/C:/Users/A-PC/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/netflix-commons/netflix-eventbus/0.3.0/netflix-eventbus-0.3.0.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/netflix-commons/netflix-infix/0.3.0/netflix-infix-0.3.0.jar, file:/C:/Users/A-PC/.m2/repository/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar, file:/C:/Users/A-PC/.m2/repository/joda-time/joda-time/2.10.3/joda-time-2.10.3.jar, file:/C:/Users/A-PC/.m2/repository/org/antlr/antlr-runtime/3.4/antlr-runtime-3.4.jar, file:/C:/Users/A-PC/.m2/repository/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/commons/commons-math/2.2/commons-math-2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/archaius/archaius-core/0.7.4/archaius-core-0.7.4.jar, file:/C:/Users/A-PC/.m2/repository/javax/ws/rs/jsr311-api/1.1.1/jsr311-api-1.1.1.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/servo/servo-core/0.10.1/servo-core-0.10.1.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/servo/servo-internal/0.10.1/servo-internal-0.10.1.jar, file:/C:/Users/A-PC/.m2/repository/com/sun/jersey/jersey-core/1.19.1/jersey-core-1.19.1.jar, file:/C:/Users/A-PC/.m2/repository/com/sun/jersey/jersey-client/1.19.1/jersey-client-1.19.1.jar, file:/C:/Users/A-PC/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.19.1/jersey-apache-client4-1.19.1.jar, file:/C:/Users/A-PC/.m2/repository/com/google/inject/guice/4.1.0/guice-4.1.0.jar, file:/C:/Users/A-PC/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar, file:/C:/Users/A-PC/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/eureka/eureka-core/1.6.2/eureka-core-1.6.2.jar, file:/C:/Users/A-PC/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.4.1/woodstox-core-asl-4.4.1.jar, file:/C:/Users/A-PC/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar, file:/C:/Users/A-PC/.m2/repository/org/codehaus/woodstox/stax2-api/3.1.4/stax2-api-3.1.4.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-archaius/1.3.5.RELEASE/spring-cloud-starter-archaius-1.3.5.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar, file:/C:/Users/A-PC/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-ribbon/1.3.5.RELEASE/spring-cloud-starter-ribbon-1.3.5.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon/2.2.2/ribbon-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon-transport/2.2.2/ribbon-transport-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/io/reactivex/rxnetty-contexts/0.4.9/rxnetty-contexts-0.4.9.jar, file:/C:/Users/A-PC/.m2/repository/io/reactivex/rxnetty-servo/0.4.9/rxnetty-servo-0.4.9.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/hystrix/hystrix-core/1.5.12/hystrix-core-1.5.12.jar, file:/C:/Users/A-PC/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar, file:/C:/Users/A-PC/.m2/repository/io/reactivex/rxnetty/0.4.9/rxnetty-0.4.9.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-codec-http/4.1.39.Final/netty-codec-http-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-transport-native-epoll/4.1.39.Final/netty-transport-native-epoll-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.39.Final/netty-transport-native-unix-common-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon-core/2.2.2/ribbon-core-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.2.2/ribbon-httpclient-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.1.1/netflix-commons-util-0.1.1.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.2.2/ribbon-loadbalancer-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar, file:/C:/Users/A-PC/.m2/repository/io/reactivex/rxjava/1.3.8/rxjava-1.3.8.jar, file:/C:/Users/A-PC/.m2/repository/com/netflix/ribbon/ribbon-eureka/2.2.2/ribbon-eureka-2.2.2.jar, file:/C:/Users/A-PC/.m2/repository/com/thoughtworks/xstream/xstream/1.4.9/xstream-1.4.9.jar, file:/C:/Users/A-PC/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar, file:/C:/Users/A-PC/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.1.8.RELEASE/spring-boot-starter-web-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.8.RELEASE/spring-boot-starter-json-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.9/jackson-datatype-jdk8-2.9.9.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.9/jackson-datatype-jsr310-2.9.9.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.9/jackson-module-parameter-names-2.9.9.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.8.RELEASE/spring-boot-starter-tomcat-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.24/tomcat-embed-core-9.0.24.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.24/tomcat-embed-el-9.0.24.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.24/tomcat-embed-websocket-9.0.24.jar, file:/C:/Users/A-PC/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.17.Final/hibernate-validator-6.0.17.Final.jar, file:/C:/Users/A-PC/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar, file:/C:/Users/A-PC/.m2/repository/org/jboss/logging/jboss-logging/3.3.3.Final/jboss-logging-3.3.3.Final.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-web/5.1.9.RELEASE/spring-web-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-beans/5.1.9.RELEASE/spring-beans-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-webmvc/5.1.9.RELEASE/spring-webmvc-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-context/5.1.9.RELEASE/spring-context-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-expression/5.1.9.RELEASE/spring-expression-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.1.8.RELEASE/spring-boot-starter-data-redis-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/data/spring-data-redis/2.1.10.RELEASE/spring-data-redis-2.1.10.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/data/spring-data-keyvalue/2.1.10.RELEASE/spring-data-keyvalue-2.1.10.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-tx/5.1.9.RELEASE/spring-tx-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-oxm/5.1.9.RELEASE/spring-oxm-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-context-support/5.1.9.RELEASE/spring-context-support-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/io/lettuce/lettuce-core/5.1.8.RELEASE/lettuce-core-5.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-common/4.1.39.Final/netty-common-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-handler/4.1.39.Final/netty-handler-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-buffer/4.1.39.Final/netty-buffer-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-codec/4.1.39.Final/netty-codec-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-transport/4.1.39.Final/netty-transport-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/netty/netty-resolver/4.1.39.Final/netty-resolver-4.1.39.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/projectreactor/reactor-core/3.2.12.RELEASE/reactor-core-3.2.12.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.1.8.RELEASE/spring-boot-starter-data-jpa-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/javax/transaction/javax.transaction-api/1.3/javax.transaction-api-1.3.jar, file:/C:/Users/A-PC/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar, file:/C:/Users/A-PC/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar, file:/C:/Users/A-PC/.m2/repository/org/hibernate/hibernate-core/5.3.11.Final/hibernate-core-5.3.11.Final.jar, file:/C:/Users/A-PC/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar, file:/C:/Users/A-PC/.m2/repository/net/bytebuddy/byte-buddy/1.9.16/byte-buddy-1.9.16.jar, file:/C:/Users/A-PC/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/A-PC/.m2/repository/org/jboss/jandex/2.0.5.Final/jandex-2.0.5.Final.jar, file:/C:/Users/A-PC/.m2/repository/org/dom4j/dom4j/2.1.1/dom4j-2.1.1.jar, file:/C:/Users/A-PC/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.4.Final/hibernate-commons-annotations-5.0.4.Final.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/data/spring-data-jpa/2.1.10.RELEASE/spring-data-jpa-2.1.10.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/data/spring-data-commons/2.1.10.RELEASE/spring-data-commons-2.1.10.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-orm/5.1.9.RELEASE/spring-orm-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-aspects/5.1.9.RELEASE/spring-aspects-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.1.8.RELEASE/spring-boot-starter-aop-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-aop/5.1.9.RELEASE/spring-aop-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/aspectj/aspectjweaver/1.9.4/aspectjweaver-1.9.4.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-configuration-processor/2.1.8.RELEASE/spring-boot-configuration-processor-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.8.RELEASE/spring-boot-starter-logging-2.1.8.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar, file:/C:/Users/A-PC/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.2/log4j-to-slf4j-2.11.2.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar, file:/C:/Users/A-PC/.m2/repository/org/slf4j/jul-to-slf4j/1.7.28/jul-to-slf4j-1.7.28.jar, file:/C:/Users/A-PC/.m2/repository/com/alibaba/druid/1.1.10/druid-1.1.10.jar, file:/C:/Users/A-PC/.m2/repository/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar, file:/C:/Users/A-PC/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar, file:/C:/Users/A-PC/.m2/repository/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-swagger2/2.8.0/springfox-swagger2-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/io/swagger/swagger-annotations/1.5.14/swagger-annotations-1.5.14.jar, file:/C:/Users/A-PC/.m2/repository/io/swagger/swagger-models/1.5.14/swagger-models-1.5.14.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-spi/2.8.0/springfox-spi-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-core/2.8.0/springfox-core-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-schema/2.8.0/springfox-schema-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-swagger-common/2.8.0/springfox-swagger-common-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-spring-web/2.8.0/springfox-spring-web-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/org/reflections/reflections/0.9.11/reflections-0.9.11.jar, file:/C:/Users/A-PC/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/mapstruct/mapstruct/1.2.0.Final/mapstruct-1.2.0.Final.jar, file:/C:/Users/A-PC/.m2/repository/io/springfox/springfox-swagger-ui/2.8.0/springfox-swagger-ui-2.8.0.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/spring-jcl/5.1.9.RELEASE/spring-jcl-5.1.9.RELEASE.jar, file:/C:/Users/A-PC/.m2/repository/com/github/penggle/kaptcha/2.3.2/kaptcha-2.3.2.jar, file:/C:/Users/A-PC/.m2/repository/com/jhlabs/filters/2.0.235-1/filters-2.0.235-1.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-eureka-client/2.0.0.M7/spring-cloud-starter-netflix-eureka-client-2.0.0.M7.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-archaius/2.0.0.M7/spring-cloud-starter-netflix-archaius-2.0.0.M7.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-netflix-ribbon/2.0.0.M7/spring-cloud-netflix-ribbon-2.0.0.M7.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-netflix-archaius/2.0.0.M7/spring-cloud-netflix-archaius-2.0.0.M7.jar, file:/C:/Users/A-PC/.m2/repository/org/springframework/cloud/spring-cloud-starter-netflix-ribbon/2.0.0.M7/spring-cloud-starter-netflix-ribbon-2.0.0.M7.jar, file:/C:/Users/A-PC/.m2/repository/net/sourceforge/jexcelapi/jxl/2.6.12/jxl-2.6.12.jar, file:/C:/Users/A-PC/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar, file:/C:/Users/A-PC/.m2/repository/javax/mail/mail/1.4.3/mail-1.4.3.jar, file:/C:/Users/A-PC/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar, file:/E:/%e8%bd%af%e4%bb%b6/IDEA%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7/IntelliJ%20IDEA%202019.2/lib/idea_rt.jar, file:/C:/Users/A-PC/.IntelliJIdea2019.2/system/captureAgent/debugger-agent.jar]
11:47:03.547 [background-preinit] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
11:47:03.548 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.17.Final
11:47:03.557 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
11:47:03.558 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
11:47:03.562 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
11:47:03.563 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
11:47:03.563 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
11:47:03.564 [background-preinit] DEBUG org.hibernate.validator.internal.xml.config.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
11:47:03.753 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
11:47:03.761 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
11:47:03.761 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.JPATraversableResolver as ValidatorFactory-scoped traversable resolver.
11:47:03.761 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
11:47:03.762 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
11:47:03.762 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
11:47:04.046 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:342)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
	at com.web.BootStrap.main(BootStrap.java:32)

该问题是因为springboot 与springcloud 的版本对应不一致所导致

需要修改pom 文件中spring cloud 的版本

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

当前的对应关系2019年9月11日 11:54:35 更新

{
	"git": {
		"commit": {
			"time": "2019-09-10T13:26:59Z",
			"id": "ba696ea"
		},
		"branch": "ba696ea5b88c33a157580b2fa2e7d3849cbd4d87"
	},
	"build": {
		"version": "0.0.1-SNAPSHOT",
		"artifact": "start-site",
		"name": "start.spring.io website",
		"versions": {
			"initializr": "0.8.0.BUILD-SNAPSHOT",
			"spring-boot": "2.1.8.RELEASE"
		},
		"group": "io.spring.start",
		"time": "2019-09-10T13:33:48.840Z"
	},
	"bom-ranges": {
		"azure": {
			"2.0.10": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE",
			"2.1.7": "Spring Boot >=2.1.0.RELEASE"
		},
		"codecentric-spring-boot-admin": {
			"2.0.6": "Spring Boot >=2.0.0.M1 and <2.1.0.M1",
			"2.1.5": "Spring Boot >=2.1.0.M1 and <2.2.0.M1"
		},
		"spring-cloud": {
			"Finchley.M2": "Spring Boot >=2.0.0.M3 and <2.0.0.M5",
			"Finchley.M3": "Spring Boot >=2.0.0.M5 and <=2.0.0.M5",
			"Finchley.M4": "Spring Boot >=2.0.0.M6 and <=2.0.0.M6",
			"Finchley.M5": "Spring Boot >=2.0.0.M7 and <=2.0.0.M7",
			"Finchley.M6": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1",
			"Finchley.M7": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2",
			"Finchley.M9": "Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE",
			"Finchley.RC1": "Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE",
			"Finchley.RC2": "Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE",
			"Finchley.SR4": "Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT",
			"Finchley.BUILD-SNAPSHOT": "Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3",
			"Greenwich.M1": "Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE",
			"Greenwich.SR2": "Spring Boot >=2.1.0.RELEASE and <2.1.9.BUILD-SNAPSHOT",
			"Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.9.BUILD-SNAPSHOT and <2.2.0.M4",
			"Hoxton.M2": "Spring Boot >=2.2.0.M4 and <2.2.0.BUILD-SNAPSHOT",
			"Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.2.0.BUILD-SNAPSHOT"
		},
		"spring-cloud-services": {
			"2.0.3.RELEASE": "Spring Boot >=2.0.0.RELEASE and <=2.0.999.BUILD-SNAPSHOT",
			"2.1.4.RELEASE": "Spring Boot >=2.1.0.RELEASE"
		},
		"spring-statemachine": {
			"2.0.0.M4": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1",
			"2.0.0.M5": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2",
			"2.0.1.RELEASE": "Spring Boot >=2.0.0.RELEASE"
		},
		"vaadin": {
			"10.0.17": "Spring Boot >=2.0.0.M1 and <2.1.0.M1",
			"14.0.4": "Spring Boot >=2.1.0.M1"
		}
	},
	"dependency-ranges": {
		"okta": {
			"1.2.1": "Spring Boot >=2.1.2.RELEASE"
		},
		"mybatis": {
			"2.0.1": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE",
			"2.1.0": "Spring Boot >=2.1.0.RELEASE"
		},
		"geode": {
			"1.2.0.BUILD-SNAPSHOT": "Spring Boot >=2.2.0.M5"
		},
		"camel": {
			"2.22.4": "Spring Boot >=2.0.0.M1 and <2.1.0.M1",
			"2.24.0": "Spring Boot >=2.1.0.M1"
		}
	}
}
1、传送门

官方公布的对应关系传送门

他会返回一个JSON 给你,就是上面的那个

2、表格表示

为了更加直观一点,用表格表示一下

Spring Boot Spring Cloud
1.2.x Angel版本
1.3.x Brixton版本
1.4.x stripes Camden版本
1.5.x Dalston版本、Edgware版本
2.0.x Finchley版本
2.1.x Greenwich.SR2

Springboot 1.5.6 升级到 2.1.8_第1张图片

3、包依赖的差异

尤里卡组件的差异

原来的

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>

需要改为

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

其它还有一些包依赖的变化,这里没有一一列出

10、启动失败

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-11 12:04:20.904 ERROR 32 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'earningPayRepo', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Disconnected from the target VM, address: '127.0.0.1:64685', transport: 'socket'

Process finished with exit code 1

项目中具备了相同名称的Bean,启动不成功,需要修改配置,允许创建相同名称的Bean

spring:
  main:
    allow-bean-definition-overriding: true

因为JPA 的repo 接口会继承自JPA的接口,项目中定义了如下接口,用于简化代码编写

@NoRepositoryBean
public interface BaseRepo<T, ID extends Serializable>
    extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {}

11、JPA 找不到表 hibernate_sequence

完整报错

2019-09-11 13:01:33.435 ERROR 7824 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at com.web.BootStrap.main(BootStrap.java:32) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 16 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) ~[hibernate-core-5.3.11.Final.jar:5.3.11.Final]
	at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 20 common frames omitted

之前代码JPA 实体主键是这么写的,数据库中没有 hibernate_sequence 表,但是仍然可以正常运行

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "id", nullable = false)
  private Long id;

升级之后,因为数据库的主键是自增主键,需要使用 IDENTITY 策略,应该改为如下方式

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "id", nullable = false)
  private Long id;

错误发生可能由于使用了 @GeneratedValue 没有指定策略,或者 使用了@GeneratedValueAUTO 策略但是数据库的ID 是自增主键

你可能感兴趣的:(框架相关,-,SpringBoot体系,#)