亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

解析spring cloud ouath2中的Eureka

 更新時間:2021年02月11日 07:53:42   作者:小黃雞1992  
這篇文章主要介紹了spring cloud ouath2中的Eureka,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

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

EurekaApplication 

@EnableEurekaServer指定為server端

@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {
 
 public static void main(String[] args) {
  SpringApplication.run(EurekaApplication.class, args);
 }
 
}

WebSecurityConfig 

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

@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以下配置的賬號密碼 在訪問頁面需要輸入的

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

 <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 出現下圖 需要填寫賬號密碼

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

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內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • 深入理解Java設計模式之享元模式

    深入理解Java設計模式之享元模式

    這篇文章主要介紹了JAVA設計模式之享元模式的的相關資料,文中示例代碼非常詳細,供大家參考和學習,感興趣的朋友可以了解下
    2021-11-11
  • springboot如何使用redis的incr創(chuàng)建分布式自增id

    springboot如何使用redis的incr創(chuàng)建分布式自增id

    這篇文章主要介紹了springboot如何使用redis的incr創(chuàng)建分布式自增id,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • 詳解RabbitMQ延遲隊列的基本使用和優(yōu)化

    詳解RabbitMQ延遲隊列的基本使用和優(yōu)化

    這篇文章主要介紹了詳解RabbitMQ延遲隊列的基本使用和優(yōu)化,延遲隊列中的元素都是帶有時間屬性的。延遲隊列就是用來存放需要在指定時間被處理的元素的隊列,需要的朋友可以參考下
    2023-05-05
  • Java多線程之FutureTask的介紹及使用

    Java多線程之FutureTask的介紹及使用

    之前介紹了線程池相關的對象,Runable Callable與Future,下面介紹FutureTask的作用,它的特性是怎樣的呢,需要的朋友可以參考下
    2021-06-06
  • Java 蒙特卡洛算法求圓周率近似值實例詳解

    Java 蒙特卡洛算法求圓周率近似值實例詳解

    這篇文章主要介紹了蒙特卡洛算法的起源,特點,以及Java編程中利用蒙特卡洛算法計算圓周率近似值的實例,需要的朋友可以參考下
    2017-09-09
  • SpringBoot RestTemplate 簡單包裝解析

    SpringBoot RestTemplate 簡單包裝解析

    這篇文章主要介紹了SpringBoot RestTemplate 簡單包裝解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-08-08
  • 解析ConcurrentHashMap: put方法源碼分析

    解析ConcurrentHashMap: put方法源碼分析

    ConcurrentHashMap是由Segment數組結構和HashEntry數組結構組成。Segment的結構和HashMap類似,是一種數組和鏈表結構,今天給大家普及java面試常見問題---ConcurrentHashMap知識,一起看看吧
    2021-06-06
  • Java在利用反射條件下替換英文字母中的值

    Java在利用反射條件下替換英文字母中的值

    今天小編就為大家分享一篇關于Java在利用反射條件下替換英文字母中的值,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • 用java實現猜數字游戲

    用java實現猜數字游戲

    這篇文章主要為大家詳細介紹了用java實現猜數字游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • springboot dynamic多數據源demo以及常見切換、事務的問題

    springboot dynamic多數據源demo以及常見切換、事務的問題

    這篇文章主要介紹了springboot dynamic多數據源demo以及常見切換、事務的問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07

最新評論