idea快速搭建spring cloud-注册中心与注册

<span>spring cloud快速搭建

  Spring Cloud是一个微服务框架,它基于spring boot, Spring Cloud提供的全套的分布式系统解决方案。 

  首先我们使用gradle来创建:

idea快速搭建spring cloud-注册中心与注册

选择JDK以及勾选Java,然后下一步

idea快速搭建spring cloud-注册中心与注册

起包名已经项目名,下一步:

idea快速搭建spring cloud-注册中心与注册

选择我们本地的gradle包,一直下一步,点击build.gradle并添加我们的依赖:

group 'com.gaofei' version '1.0-SNAPSHOT' //gradle使用的插件 apply plugin: 'java' //gradle使用spring-boot打包更方便 apply plugin: 'spring-boot' //jdk的版本号 sourceCompatibility = 1.8 //本项目的 dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' } //由于本次创建gradle未出现src,由以下代码来解决 task "create-dirs" << { sourceSets*.java.srcDirs*.each { it.mkdirs() } sourcScts*.resources.srcDirs*.each{ it.midirs() } } //编译构建时的配置 buildscript { ext{ springBootVersion='1.5.10.RELEASE' //springBootVersion是自己定义的变量 里面写的是springboot插件的版本 } repositories { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} jcenter() mavenCentral() maven{ url "http://repo.spring.io/snapshot" } maven{ url "http://repo.spring.io/milestone" } maven{ url "http://repo.spring.io/release" } maven{ url 'http://repo.spring.io/plugins-snapshot' } } dependencies{ classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")//指的是springboot的一个插件 } } //统一所有项目的配置 就是对所有的模块进行统一配置 所有以后的模块都不用再配置 allprojects { group 'com.gaofei' //分组 version '1.0-SNAPSHOT' //版本号 ext{ springCloudVersion='Edgware.SR2' } //所有项目都会引用的阿里云里的maven repositories { maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} jcenter() mavenCentral() maven{ url "http://repo.spring.io/snapshot" } maven{ url "http://repo.spring.io/milestone" } maven{ url "http://repo.spring.io/release" } maven{ url 'http://repo.spring.io/plugins-snapshot' } } } //统一所有子项目的配置 subprojects { apply plugin: 'java' apply plugin: 'idea' apply plugin: 'spring-boot' dependencies { compile('org.springframework.boot:spring-boot-starter-web'){ //使用undertow来代替tomacat exclude module:"spring-boot-starter-tomcat" } //替代tomcat compile 'org.springframework.boot:spring-boot-starter-undertow' //健康检查 compile 'org.springframework.boot:spring-boot-starter-actuator' dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' } } //版本控制插件 dependencyManagement{ imports{ mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpjyzz.html