亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

解析spring cloud ouath2中的Eureka

瀏覽:103日期: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

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

@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>

當(dāng)訪問localhost:7001 出現(xiàn)下圖 需要填寫賬號密碼

解析spring cloud ouath2中的Eureka

在其他服務(wù)注冊時(shí) 也需要指定賬號密碼

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

到此這篇關(guān)于spring cloud ouath2中的Eureka的文章就介紹到這了,更多相關(guān)spring cloud ouath2內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 国产麻豆精品入口在线观看 | 国产大量女主播精品视频 | 久久精品国产精品亚洲综合 | 777奇米影视笫四色88me久久综合 | 你懂的国产 | 国产精品又黄又爽又色视频 | 久久精品免看国产 | 第一页综合 | 国产精品视频大全 | 天天狠狠色噜噜 | 精品一区二区久久久久久久网精 | 国产成人免费手机在线观看视频 | 欧美日韩亚洲国产千人斩 | 免费毛片软件 | 俄罗斯胖老太与小伙交 | 国产欧美成人xxx视频 | 久久精品国产欧美 | 看国产一级毛片 | 尤物国产 | 日韩国产精品欧美一区二区 | 欧美黑人在线观看 | 国产视频二区在线观看 | 日本黄大片免播放视播放器 | 久草久爱 | 伊人久久综合 | 欧美亚洲国产精品久久久 | 777成了人精品视频 777色淫网站女女 | 在线观看福利视频在线观看 | 国产一级毛片网站 | 狠狠的日视频 | 国产又色又爽免费视频 | 成人免费视频一区 | 欧美成人一区二区 | 久久精品亚洲热综合一本奇米 | 天天更新天天久久久更新影院 | 久久久精品久久久久特色影视 | 男女乱淫真视频免费一级毛片 | 人人九九 | 国产网站精品 | 黄色片91 | 亚洲三级在线 |