国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - idea快速搭建spring cloud注冊中心與注冊的方法

idea快速搭建spring cloud注冊中心與注冊的方法

2021-05-18 11:13IT高飛 Java教程

這篇文章主要介紹了idea快速搭建spring cloud注冊中心與注冊的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

spring cloud快速搭建

spring cloud是一個微服務(wù)框架,它基于spring boot, spring cloud提供的全套的分布式系統(tǒng)解決方案 。 

首先我們使用gradle來創(chuàng)建:

idea快速搭建spring cloud注冊中心與注冊的方法

選擇jdk以及勾選java,然后下一步

idea快速搭建spring cloud注冊中心與注冊的方法

起包名已經(jīng)項目名,下一步:

idea快速搭建spring cloud注冊中心與注冊的方法

選擇我們本地的gradle包,一直下一步,點(diǎn)擊build.gradle并添加我們的依賴:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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'
}
 
//由于本次創(chuàng)建gradle未出現(xiàn)src,由以下代碼來解決
task "create-dirs" << {
  sourcesets*.java.srcdirs*.each {
    it.mkdirs()
  }
  sourcscts*.resources.srcdirs*.each{
    it.midirs()
  }
}
 
 
//編譯構(gòu)建時的配置
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的一個插件
  }
}
 
 
 
//統(tǒng)一所有項目的配置 就是對所有的模塊進(jìn)行統(tǒng)一配置 所有以后的模塊都不用再配置
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' }
  }
}
 
//統(tǒng)一所有子項目的配置
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}"
    }
  }
 
}

通過注釋可以看到各個代碼塊的作用,這里我們是用阿里云的倉庫

接下來我們開始建eureka注冊中心,通過new->module再建gradle項目來創(chuàng)建

idea快速搭建spring cloud注冊中心與注冊的方法

在build中添加eureka-server依賴

?
1
2
//表示自己是一個服務(wù)器
  compile 'org.springframework.cloud:spring-cloud-starter-eureka-server'

接下來在application.yml中配置

?
1
2
3
4
5
6
7
8
9
server:
 port: 8000
spring:
 application:
  name: register-center #起個名字
eureka:
 client:
  register-with-eureka: false #啟動時不注冊表明自己是一個注冊中心
  fetch-registry: false

啟動類

?
1
2
3
4
5
6
7
8
@springbootapplication
@enableeurekaserver//表明自己是注冊中心
public class registercenterprovider {
  public static void main(string[] args) {
 
    springapplication.run(registercenterprovider.class);
  }
}

啟動:

idea快速搭建spring cloud注冊中心與注冊的方法

這就表示注冊中心啟動成功

下面創(chuàng)建服務(wù)注冊到服務(wù)中心

創(chuàng)建一個gradle module 項目

idea快速搭建spring cloud注冊中心與注冊的方法

在build.gradle中添加thymeleaf組件,eureka客戶端組件的依賴

?
1
2
3
4
//thymeleaf組件
  compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
  //eureka客戶端組件
  compile 'org.springframework.cloud:spring-cloud-starter-eureka'

在application.yml中配置:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
server:
 port: 8001
spring:
 application:
  name: project-shopping-mall #注冊在注冊中心的名字,它會進(jìn)行鍵值對映射url
 thymeleaf:
  cache: false #關(guān)閉緩存
eureka:
 client:
  service-url:
   defaultzone: http://localhost:8000/eureka/ #注冊到注冊中心
 instance:
  prefer-ip-address: true #用兩種方式進(jìn)行注冊,一種是使用主機(jī)名注冊,一種是使用ip地址進(jìn)行注冊,這里使用ip地址進(jìn)行注冊

啟動類:

?
1
2
3
4
5
6
7
@springbootapplication
@enablediscoveryclient //表示eureka客戶端
public class shoppingmallprovider {
  public static void main(string[] args) {
    springapplication.run(shoppingmallprovider.class);
  }
}

啟動:

idea快速搭建spring cloud注冊中心與注冊的方法

成功!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://www.cnblogs.com/itgaofei/p/9329375.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 成人av在线电影 | 久草视频观看 | av片免费| 国产精品成人在线视频 | 91在线观看视频 | 久久夜夜 | 日韩视频在线一区 | 久久人人网 | 亚洲国产精品久久人人爱 | 免费一区二区 | 久久精品国产清自在天天线 | 91操碰 | 国产精品美女久久久久久免费 | 亚洲男人的天堂视频 | 欧美精品在线一区 | 日韩一区二区三区在线视频 | 欧美劲爆第一页 | 国产精品一区二区无线 | 亚洲欧美日韩在线 | 久久99久 | 国产欧美精品一区二区三区 | 午夜在线电影 | 美女毛片 | 二区在线视频 | 欧洲精品久久久久毛片完整版 | 久热免费在线视频 | 成人a在线 | 中文字幕在线三区 | 欧美一区二区日韩一区二区 | 午夜色播 | 性高潮一级片 | 国产精品亚洲成在人线 | 国产毛片一区二区 | 91精品综合久久久久久五月天 | 成人免费乱码大片a毛片软件 | 国产另类ts人妖一区二区 | 亚洲 欧美 日韩 在线 | 超碰日韩 | 免费裸体视频网站 | 91精品国产一区二区三区 | 日本中文字幕在线 |