gradle微服务依赖模版

1、父工程依赖模版

注: ext里的内容需要配合设置云效仓库参数到环境变量及gradle使用-CSDN博客使用

Groovy 复制代码
plugins {  
	id 'org.springframework.boot' version '2.3.12.RELEASE'  
	// 引入dependency-management插件  
	id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}  
  
group = 'com.fafa'  
  
subprojects {  
	apply plugin: 'org.springframework.boot'  
	apply plugin: 'io.spring.dependency-management'  
	apply plugin: 'java'  
	  
	sourceCompatibility = 11  
	targetCompatibility = 11  
	  
	ext {  
		MAVEN_REPO_RELEASE_URL = System.getenv('MAVEN_REPO_RELEASE_URL')  
		MAVEN_REPO_SNAPSHOT_URL = System.getenv('MAVEN_REPO_SNAPSHOT_URL')  
		MAVEN_DEPLOY_USER = System.getenv('MAVEN_DEPLOY_USER')  
		MAVEN_DEPLOY_PASSWORD = System.getenv('MAVEN_DEPLOY_PASSWORD')  
	}  
	  
	repositories {  
		maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }  
		maven {  
			url 'https://maven.aliyun.com/repository/public'  
		}  
		maven { url "https://repo.spring.io/milestone" }  
		maven { url "https://plugins.gradle.org/m2/" }  
		maven {  
			credentials {  
				username MAVEN_DEPLOY_USER  
				password MAVEN_DEPLOY_PASSWORD  
			}  
			url MAVEN_REPO_RELEASE_URL  
		}  
		maven {  
			credentials {  
				username MAVEN_DEPLOY_USER  
				password MAVEN_DEPLOY_PASSWORD  
			}  
			url MAVEN_REPO_SNAPSHOT_URL  
		}  
		mavenCentral()  
	}  
	  
	configurations{  
	// implementation {  
	// exclude group: 'com.alibaba.nacos', module: 'nacos-client'  
	// }  
	}  
	  
	dependencyManagement {  
		imports { mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:2.2.10-RC1" }  
		imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR12" }  
	}  
	  
	dependencies {  
		//Spring Boot Web 启动器  
		implementation 'org.springframework.boot:spring-boot-starter-web'  
		  
		compileOnly 'org.projectlombok:lombok'  
		runtimeOnly 'mysql:mysql-connector-java'  
		annotationProcessor 'org.projectlombok:lombok'  
		  
		testImplementation 'org.springframework.boot:spring-boot-starter-test'  
	}  
	  
	test {  
		useJUnitPlatform()  
	}  
	  
	sourceSets {  
		main {  
			resources {  
				srcDirs = ['src/main/resources']  
			}  
		}  
	}  
	  
	tasks.withType(JavaCompile) {  
		options.encoding = "UTF-8"  
		doLast {  
			copy {  
				from sourceSets.main.resources  
				into "$buildDir/resources/main"  
			}  
		}  
	}  
}

2、子工程依赖模版

Groovy 复制代码
group = 'com.fafa.order'  
version = '1.0'  
description = "order-service"  
  
apply plugin: 'application'  
  
dependencies {  
	//mybatis  
	implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.1'  
}
相关推荐
stark张宇2 天前
微服务架构必备:Gin + gRPC + Consul + Nacos + GORM 打造用户服务
微服务·gin·grpc
阿里云云原生5 天前
MSE Nacos Prompt 管理:让 AI Agent 的核心配置真正可治理
微服务·云原生
阿里云云原生5 天前
阿里云微服务引擎 MSE 及 API 网关 2026 年 1 月产品动态
微服务
麦聪聊数据6 天前
统一 Web SQL 平台如何收编企业内部的“野生数据看板”?
数据库·sql·低代码·微服务·架构
云司科技codebuddy6 天前
技术支持过硬Trae核心代理
大数据·运维·python·微服务
递归尽头是星辰6 天前
微服务事务分级治理:从 Seata 全模式到 TDSQL 实战
微服务·云原生·架构·分布式事务·事务分级治理
没有bug.的程序员6 天前
订单系统重构史诗:从单体巨兽到微服务矩阵的演进、数据一致性内核与分布式事务
java·微服务·矩阵·重构·分布式事务·数据一致性·订单系统
江西理工大学小杨6 天前
高性能 C++ 社交平台4:基于 Boost.Beast 的 WebSocket 网关实现
c++·websocket·微服务
麦聪聊数据6 天前
数据流通的最后一公里:SQL2API 在企业数据市场中的履约架构实践
数据库·sql·低代码·微服务·架构
知识即是力量ol7 天前
微服务架构:从入门到进阶完全指南
java·spring cloud·微服务·nacos·架构·gateway·feign