首页 > 编程知识 正文

gradle创建springboot,gradle搭建springboot

时间:2023-05-03 15:50:48 阅读:267930 作者:877

//构建脚本(给脚本用的脚本)buildscript { //存储一个属于gradle的变量,整个工程都能用,可通过gradle.ext.springBootVersion使用 ext { springBootVersion = '2.1.2.RELEASE' } /*配置仓库地址,从而找到外部依赖 按照你在文件中(build.gradle)仓库的顺序寻找所需依赖(如jar文件), 如果在某个仓库中找到了,那么将不再其它仓库中寻找 */ repositories { //mavenLocal()本地库,local repository(${user.home}/.m2/repository) mavenCentral()//maven的中央仓库 //阿里云Maven远程仓库 maven { url "http://maven.aliyun.com/nexus/content/groups/public/" } } /*配置springboot插件加载 */ dependencies { // classpath 声明说明了在执行其余的脚本时,ClassLoader 可以使用这些依赖项 classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }}//使用以下插件apply plugin: 'java'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'group = 'com.example'version = '0.0.1-SNAPSHOT'sourceCompatibility = '1.8'//jvm版本要求// 定义仓库repositories { maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'} maven{url 'https://mvnrepository.com/'} mavenCentral()}// 定义依赖:声明项目中需要哪些依赖dependencies { compile 'org.springframework.boot:spring-boot-starter' compile('org.springframework.boot:spring-boot-starter-web')//引入web模块,springmvc compile 'org.springframework.boot:spring-boot-starter-test'}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。