gradle微服务依赖模版

发布于:2025-07-21 ⋅ 阅读:(14) ⋅ 点赞:(0)

1、父工程依赖模版

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

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、子工程依赖模版

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'  
}


网站公告

今日签到

点亮在社区的每一天
去签到