亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目的超詳細教程

瀏覽:79日期:2023-09-24 14:36:14

環境介紹 IDEA

我用的是2020.2

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目的超詳細教程

Gradle

安裝參考 Gradle安裝配置

我這安裝的是6.6.1

C:Usersherion>gradle -v------------------------------------------------------------Gradle 6.6.1------------------------------------------------------------Build time: 2020-08-25 16:29:12 UTCRevision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3Kotlin: 1.3.72Groovy: 2.5.12Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020JVM: 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>:tasksFor example, try running gradle :gradle-common:tasksDeprecated 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_warningsBUILD SUCCESSFUL in 4s1 actionable task: 1 executed

編譯項目

$ gradle buildDeprecated 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_warningsBUILD SUCCESSFUL in 5s12 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:publishMavenJavaPublicationToMavenRepositoryDeprecated 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_warningsBUILD SUCCESSFUL in 24s16 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 創建多模塊項目的超詳細教程

瀏覽器訪問http://localhost:8080/helllo?name=herion

IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目的超詳細教程

demo 源碼地址

到此這篇關于IDEA 2020.2 +Gradle 6.6.1 + Spring Boot 2.3.4 創建多模塊項目的文章就介紹到這了,更多相關idea+Gradle+springboot多模塊項內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 91青青青青青爽在线 | 亚洲综合在线观看一区www | 国产精品久久国产三级国电话系列 | 久久久国产精品免费看 | 宅男69免费永久网站 | 亚洲成熟xxxxx电影 | 成人午夜网 | 污香蕉视频在线观看 | 亚洲欧洲中文日产 | 青青久在线精品视频 | 国产一级爱片在线播放 | 欧美日韩午夜精品不卡综合 | 月婷婷色狠狠 | 一级特黄录像免费播放冫 | 国产伦理播放一区二区 | 国产日韩欧美综合一区二区三区 | 男人午夜影院 | 国产精品天天看天天爽 | 成人黄色片视频 | 免费岛国片 | 天天狠狠色综合图片区 | 国产亚洲欧美日韩综合另类 | 娇小性色xxxxx中文 | 麻豆传媒2021精品传媒一区 | 视频黄色免费 | 日本亚洲国产精品久久 | 亚洲欧美啪啪 | 日本高清在线一区 | 国产视频播放 | 在线看一区| 国产成人精品cao在线 | 黄毛片一级毛片 | 国产精品jizz观看 | 亚洲欧美日韩国产一区二区精品 | 毛片一级| 国产偷2018在线观看午夜 | 24小时中文乱码字幕在线观看 | 国产精品视频久 | 色九九亚洲偷偷动态图 | 国产一级毛片欧美视频 | 国产成人免费午夜性视频 |