Springboot2.0 升级(Gradle工程)

Springboot2.0 等了很久,下周样子终于有正式版本了。今天有空对原项目进行了升级。

变化还是挺大的,然后打包后项目小10M 

项目环境信息: Springboot 1.5.10 + Gradle 4.5.1 + redis+mongodb + es

一、Gradle配置修改

打包命令由gradle build 变成 gradle bootJar 或 gradle bootWar

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springboot_version}"
    }
}

allprojects {
    apply plugin: "java"
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'application'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    dependencies {
        compile("org.projectlombok:lombok")
        compile("org.springframework.boot:spring-boot-starter")
    }

    repositories {
        repositories {
            maven { url ALY_MAVEN_REPOURL }
            maven { url "https://repo.spring.io/snapshot" }
            maven { url "https://repo.spring.io/milestone" }

        }
    }

    configurations {
        all*.exclude module: 'commons-logging'
    }

    //这里一定得要。在多模块下,不然编译失败,因为不会把信赖模块给打包。
    jar {
        enabled = true
    }

    bootJar {
        classifier = 'app'
    }
}

另外这个错误解决是:

你启动的bootJar命令,必须在有启动类的项目下执行bootJar。 不然会遇到下面这个问题,springBoot默认是根据找当前目录下的引导类.

  解决错误:The value of a manifest attribute must not be null (Key=Start-Class).

二、JPA -Repository 修改(较大)

这里主要涉及Repository接口几个方法修改:

  1. save --> saveAll
  2. findOne--> findById
  3. delete  -->deleteById

三、Application启动类修改

    原来需要继承SpringBootServletInitializer ,现在不需要

四、application配置文件修改

  1. server.context-path -->server.servlet.context-path
  2. spring.http --spring.servlet
  3. thymeleaf模式LEGAYHTML5 --> html

五、ElasticSearch升级

六、其它就是一些类变化,暂时没用到所以也没知道

关上打包后的截图.

 

转载于:https://my.oschina.net/tangdu/blog/1625336

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值