中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

發布時間:2020-10-29 18:43:51 來源:億速云 閱讀:187 作者:Leah 欄目:開發技術

這期內容當中小編將會給大家帶來有關IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

Gradle

安裝參考 Gradle安裝配置

我這安裝的是6.6.1

C:\Users\herion>gradle -v

------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------

Build time:  2020-08-25 16:29:12 UTC
Revision:   f2d1fb54a951d8b11d25748e4711bec8d128d7e3

Kotlin:    1.3.72
Groovy:    2.5.12
Ant:     Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:     1.8.0_211 (Oracle Corporation 25.211-b12)
OS:      Windows 10 10.0 amd64

創建 gradle-parent New Project --> Spring Initalizr 選擇jdk版本,我這里使用1.8

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目Next

–> 根據需求修改 Group、Artifact、version 、Type、name、package 等,選擇所需依賴創建項目

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

創建成功后刪除src 目錄

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目 

創建子模塊 gradle-demo

選中gradle-parent–> new -->Module

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

創建子模塊操作與創建gradle-parent 雷同,這里就不做復述了,創建好gradle-demo后在gradle-parent的settings.gradle 中引入模塊依賴 include ‘gradle-demo'

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

刪除gradle-demo 中settings.gradle文件,否則不能喝gradle-parent建立依賴關系

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

定義gradle 自身所需資源

buildscript {
  ext {
    springBootVersion = '2.3.4.RELEASE'
    springBootManagementVersion = '1.0.8.RELEASE'
    springCloudVersion = 'Hoxton.SR6'
    REPOSITORY_HOME = "http://maven.aliyun.com"
  }
  repositories {
    maven { url '${REPOSITORY_HOME}/nexus/content/groups/public/' }
    mavenCentral()
    maven { url 'https://repo.spring.io/snapshot' }
    maven { url 'https://repo.spring.io/milestone' }
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath("io.spring.gradle:dependency-management-plugin:${springBootManagementVersion}")
  }
}

修改gradle-parent項目build.gradle 配置全項目通用配置

allprojects {
  apply plugin: 'java'
  apply plugin: 'idea'
  group = 'com.herion'
  sourceCompatibility = JavaVersion.VERSION_1_8
  targetCompatibility = JavaVersion.VERSION_1_8
}

子項目通用配置

subprojects {
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
  //倉庫
  repositories {
    maven { url '${REPOSITORY_HOME}/nexus/content/groups/public/' }
    mavenCentral()
    maven { url 'https://repo.spring.io/snapshot' }
    maven { url 'https://repo.spring.io/milestone' }
  }

  dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
      exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
  }

  dependencyManagement {
    imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
    imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" }
  }

  test {
    useJUnitPlatform()
  }
}

發布插件配置

 /**
   * 發布插件
   */
  publishing {
    publications {
      mavenJava(MavenPublication) {
        from components.java
        versionMapping {
          usage('java-api') {
            fromResolutionOf('runtimeClasspath')
          }
          usage('java-runtime') {
            fromResolutionResult()
          }
        }
      }
    }
    // 發布倉庫
    repositories {
      maven {
        // TODO 換成自己的私服地址
        def releasesRepoUrl = "http://my.repo.com/nexus/repository/maven-releases"
        def snapshotsRepoUrl = "http://my.repo..com/nexus/repository/maven-snapshots"
        url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
        credentials {
          username nexusUser
          password nexusPassword
        }
      }
    }
  }

  configurations {
    [apiElements, runtimeElements].each {
      it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
      it.outgoing.artifact(bootJar)
    }
  }

驗證

Gradle 查看所有項目

 gradle projects
> Task :projects
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'gradle-parent'
+--- Project ':gradle-common'
+--- Project ':gradle-demo'
\--- Project ':gradle-demo2'

To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :gradle-common:tasks

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed

編譯項目

$ gradle build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 5s
12 actionable tasks: 12 up-to-date

執行結果

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

發布jar包到nexus 命令

$ gradle publishMavenJavaPublicationToMavenRepository
> Task :gradle-common:publishMavenJavaPublicationToMavenRepository
> Task :gradle-demo:publishMavenJavaPublicationToMavenRepository
> Task :gradle-demo2:publishMavenJavaPublicationToMavenRepository
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 24s
16 actionable tasks: 13 executed, 3 up-to-date

執行結果

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目 

gradle-demo 驗證 啟動項目

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目

上述就是小編為大家分享的IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

内黄县| 江达县| 资讯| 五华县| 普兰县| 磐安县| 阿拉善左旗| 伊川县| 旅游| 栖霞市| 丹阳市| 伊宁县| 甘南县| 崇义县| 望谟县| 容城县| 石台县| 溧水县| 全州县| 谷城县| 白玉县| 周口市| 哈密市| 和平县| 延吉市| 星子县| 纳雍县| 林口县| 浏阳市| 时尚| 南汇区| 罗田县| 普兰县| 庆元县| 封开县| 罗城| 东台市| 太康县| 雷州市| 四川省| 扶风县|