激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|JavaScript|易語言|

服務器之家 - 編程語言 - Java教程 - 解析spring cloud ouath2中的Eureka

解析spring cloud ouath2中的Eureka

2021-08-08 11:44小黃雞1992 Java教程

這篇文章主要介紹了spring cloud ouath2中的Eureka,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

老生常談的配置 但是還是需要說明一下

EurekaApplication 

@EnableEurekaServer指定為server端

?
1
2
3
4
5
6
7
8
9
@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
 
 public static void main(String[] args) {
  SpringApplication.run(EurekaApplication.class, args);
 }
 
}

WebSecurityConfig 

看到這眼熟不呢 沒錯 Eureka也開啟spring security 在訪問前臺頁面時也需要輸入賬號密碼

?
1
2
3
4
5
6
7
8
9
10
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
 
 @Override
 protected void configure(HttpSecurity http) throws Exception {
  super.configure(http);
  http.csrf().disable().httpBasic();
 }
}

application.yml

security:user以下配置的賬號密碼 在訪問頁面需要輸入的

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
server:
 port: 7001
spring:
 application:
 name: eureka
 security:
 user:
  name: admin
  password: xxxxxxxxxx
eureka:
 client:
 fetch-registry: false
 register-with-eureka: false
 service-url:
  defaultZone: http://admin:Xk38CNHigBP5jK75@localhost:5001/eureka
 instance:
 hostname: localhost
 prefer-ip-address: true
logging:
 config: classpath:logback.xml
 level:
 root: info

pom.xml

?
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
<dependencies>
 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
 </dependency>
 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
 <dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
 </dependency>
 
 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
  <exclusions>
   <exclusion>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
 <dependency>
  <groupId>org.springframework.security</groupId>
  <artifactId>spring-security-test</artifactId>
  <scope>test</scope>
 </dependency>
</dependencies>

當訪問localhost:7001 出現下圖 需要填寫賬號密碼

解析spring cloud ouath2中的Eureka

在其他服務注冊時 也需要指定賬號密碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
eureka:
 instance:
 hostname: ${spring.cloud.client.ip-address}
 prefer-ip-address: true
 instance-id: ${eureka.instance.hostname}:${server.port}
 //與server一致
 client:
 security:
  basic:
  user: admin
  password: xxxxxxxxxxx
 service-url:
  defaultZone: http://${eureka.client.security.basic.user}:${eureka.client.security.basic.password}@localhost:7001/eureka

到此這篇關于spring cloud ouath2中的Eureka的文章就介紹到這了,更多相關spring cloud ouath2內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/qq_20143059/article/details/113759124

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日韩黄色片网站 | 999久久国产 | 色视频91| sm高h视频 | 久久精片 | 电影91 | 91中文字幕在线观看 | 精品国产一区二区三 | 国产精品av久久久久久无 | 国产精品一区99 | 亚洲欧美爱爱 | 男男啪羞羞视频网站 | h视频免费在线 | 免费黄色成人 | 中文字幕亚洲情99在线 | 亚洲精品无码不卡在线播放he | 九九热精品在线播放 | 国产精品视频yy9299一区 | 美国av免费看 | 12av毛片| 久久久麻豆 | www.99xxxx.com| 韩国精品久久久 | 国产精品亚洲一区二区三区久久 | 成人在线免费观看网址 | av影院在线 | 欧美精品久久久久久久久久 | aaaaaaa毛片 | 亚洲午夜免费 | 羞羞草视频 | 美女亚洲 | 99在线啪 | 亚洲影院在线观看 | 日韩欧美电影在线观看 | 国产精品一区2区3区 | 日日摸夜夜骑 | 久久久鲁| 久草在线资源观看 | 12av电影| 黄免费观看视频 | 免费在线一级毛片 |