springboot gradle 使用过程中遇到的问题小结(2)

时间:2022-06-25
本文章向大家介绍springboot gradle 使用过程中遇到的问题小结(2),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

想要打包api层,然后出现错误:

Plugin request for plugin already on the classpath must not include a version

新建的项目中默认的build.gradle中是:

id 'org.springframework.boot' version '2.1.6.RELEASE'

可以修改为:

buildscript {
    ext {
        springBootVersion = '2.1.6.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
//    id 'org.springframework.boot' version '2.1.6.RELEASE'
    id 'java'
}

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

即可解决问题