av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

解析spring cloud ouath2中的Eureka

瀏覽:110日期:2023-07-23 11:31:29

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

EurekaApplication

@EnableEurekaServer指定為server端

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

WebSecurityConfig

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

@Configuration@EnableWebSecuritypublic 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: 7001spring: application: name: eureka security: user: name: admin password: xxxxxxxxxxeureka: client: fetch-registry: false register-with-eureka: false service-url: defaultZone: http://admin:Xk38CNHigBP5jK75@localhost:5001/eureka instance: hostname: localhost prefer-ip-address: truelogging: 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 出現下圖 需要填寫賬號密碼

解析spring cloud ouath2中的Eureka

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

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內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: av免费网址 | 成人久久一区 | 成人性生交大片免费看r链接 | 插插宗合网| 91综合在线视频 | 人人玩人人添人人澡欧美 | 国产精品伦理一区 | 免费艹逼视频 | 中文字幕二区 | 91人人看| 成年人网站免费 | 亚洲国产一区二区三区 | 成人精品国产一区二区4080 | 久久99深爱久久99精品 | 97avcc| a级在线观看 | 中文字幕精品一区二区三区精品 | 一区二区免费视频 | 成人av看片 | 国产在线一区二 | 国产精品夜间视频香蕉 | 日本不卡高字幕在线2019 | 亚洲精品视频一区二区三区 | 一区二区三区四区免费视频 | 亚洲成av | 久久久精品天堂 | 日韩www | 午夜影院在线视频 | 一区二区三区中文字幕 | 欧美日韩中文字幕 | 欧美精品在线观看 | 国产成人精品999在线观看 | 中文字幕在线视频观看 | 久久久久久影院 | 99久久精品视频免费 | 亚洲精选一区二区 | 国产免费一区二区三区网站免费 | 欧美日本韩国一区二区 | 国产乱码精品一区二区三区中文 | 7777在线视频免费播放 | 性做久久久久久免费观看欧美 |