springboot maven項目轉gradle的完整方法


1、maven轉gradle的方法:在項目根目錄下,使用命令行工具,輸入如下內容:

gradle init --type.pom

 2、springboot項目的 build.gradle內容示例如下(注意部分內容需要自己添加進去):

/*
 * This file was generated by the Gradle 'init' task.
 */
buildscript {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    }
    dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE") }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
repositories {
    mavenLocal()
    maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter:2.1.6.RELEASE'
    compile 'org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE'
    compile 'org.springframework.boot:spring-boot-starter-undertow:2.1.6.RELEASE'
    compile 'org.postgresql:postgresql:42.2.5'
    compile 'com.baomidou:mybatis-plus-boot-starter:3.1.2'
    compile 'com.alibaba:druid-spring-boot-starter:1.1.16'
    compile 'org.springframework.security:spring-security-core:5.1.5.RELEASE'
    compile 'org.springframework:spring-tx:5.1.8.RELEASE'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'org.apache.commons:commons-collections4:4.1'
    compile 'joda-time:joda-time:2.10.3'
    compile 'com.spring4all:swagger-spring-boot-starter:1.8.0.RELEASE'
    annotationProcessor 'org.projectlombok:lombok:1.18.8' compileOnly 'org.projectlombok:lombok:1.18.8' testAnnotationProcessor 'org.projectlombok:lombok:1.18.8' testCompileOnly 'org.projectlombok:lombok:1.18.8'
    testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.6.RELEASE'
}

group = 'com.river'
version = '0.0.1-SNAPSHOT'
description = 'PostgrePlus'
sourceCompatibility = '1.8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

 3、打包:tasks->build->bootJar

   4、運行,找到項目build\libs對應的jar包,用java -jar XX.jar執行即可:

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM