升级spring boot从1.3.2.RELEASE到1.5.1.RELEASE

本文介绍从Spring Boot 1.3.2.RELEASE升级到1.5.1.RELEASE的过程及关键变更,包括TestRestTemplate调整、@Transactional默认配置、新增特性如Spring Session存储类型配置、Apache Kafka支持等。同时记录了升级中遇到的具体问题及解决办法。
摘要由CSDN通过智能技术生成

    升级公司framework依赖的spring boot版本,从1.3.2.RELEASE升级到1.5.1.RELEASE

解决方案:

1.spring boot版本主要更新内容

  • Spring Boot 1.4.0 Release Notes  
    1) TestRestTemplate:the TestRestTemplate class no longer directly extends RestTemplate (although it continues to offer the same methods). This allows TestRestTemplate to be configured as a bean without it being accidentally injected. If you need access to the actual                 underlying RestTemplate use the getRestTemplate() method.

          2) @Transactional:default to cglib proxies When Boot auto-configures the transaction management, proxyTargetClass is now set to true

          3) Test improvements:Spring Boot 1.4 includes a major overhaul of testing support. Test classes and utilities are now provided in dedicated spring-boot-test and spring-boot-test-autoconfigure jars (although most users will continue to pick them up via the spring-boot-starter-       test "Starter"). We’ve added AssertJ, JSONassert and JsonPath dependencies to the test starter

         1)  Spring Session store:Previously, if you had Spring Session and Redis with no particular configuration, Redis was automatically used to store sessions. You now need to specify the store type; existing users of Spring Session with Redis should add the following to their configuration:
        spring.session.store-type=redis
         2) Apache Kafka support:Spring Boot 1.5 include auto-configuration support for Apache Kafka via the spring-kafka project. To use Kafka simply include the spring-kafka`depenency and configure the appropriate `spring.kafka.* application properties
         3) LDAP support:Spring Boot now offers auto-configuration for any compliant LDAP server as well as support for the embedded in-memory LDAP server from Unbounded.See the documentation for more details.


2. 升级过程中遇到的问题

  • spring boot中SpringBootServletInitializer类已经修改,需要对公司framework框架中ApplicationStarter进行重写,修改run方法

    //    @Override
    //    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    //        return application.sources(CoreConfig.class);
    //    }
     
         public  static  void  run(Class<?> assemblyClass, String[] args) {
             if  (instance ==  null ) {
                 synchronized  (ApplicationStarter. class ) {
                     if  (instance ==  null ) {
                         logger.info( "start run a new instance." );
     
                         instance =  new  ApplicationStarter()
                             .configure(
                                 new  SpringApplicationBuilder(CoreConfig. class , ApplicationStarter. class , assemblyClass))
                             .profiles( "localResource" "healthCheck" ).properties(defaultProperties())
                             .run(args);
     
                         checkAppicationName(instance);
                     else  {
                         logger.warn( "instance is not null, can't run a new one." );
                     }
                 }
             else  {
                 logger.warn( "instance is not null, can't run a new one." );
             }
         }
  • FF4j\druid ServletRegistrationBean类改变

    //升级前
    import  org.springframework.boot.web.servlet.ServletRegistrationBean;
     
    //升级后 
    import  org.springframework.boot.context.embedded.ServletRegistrationBean;
  • 测试案例中的 TestRestTempalte已经从spring-boot release包中移除,需引入spring-boot-starter-test
  • @Transactional默认开启cglib代理,导致FF4J无法使用,已把问题提交给FF4J作者
  • @SpringApplicationConfiguration已经被废弃,可以用@ContextConfiguration替换
  • 测试案例需要进行修改,并引入spring-boot-starter-test 
  • 升级前jar包大小75447KB,升级后87010KB
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值