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

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

解析spring cloud ouath2中的Eureka

瀏覽:111日期: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
相關文章:
主站蜘蛛池模板: 91社区在线观看高清 | 国产999精品久久久久久 | 91原创视频 | 中文在线日韩 | 午夜精品久久久久久久久久久久 | 欧美成年视频 | 国产精品视频观看 | 亚洲精品在线免费观看视频 | 九七午夜剧场福利写真 | 亚洲精品www.| av一级久久 | 成人免费视频网站在线看 | 午夜视频免费网站 | 国产精品一区二区三区四区五区 | 中文字幕在线人 | 97影院2| 精品欧美一区二区三区 | 亚洲成人第一页 | 超碰电影 | 欧美日韩在线观看一区二区三区 | 91精品国产91久久久久久吃药 | 亚洲欧美国产毛片在线 | 成人区精品一区二区婷婷 | 粉嫩一区二区三区国产精品 | 亚洲欧美中文字幕 | 亚洲天堂av一区 | 在线电影日韩 | 羞羞视频网页 | 香蕉久久a毛片 | 久久综合一区二区三区 | 男女视频在线观看免费 | 成年网站在线观看 | 在线看片福利 | 狠狠干天天干 | 免费麻豆视频 | 日韩精品三区 | 91免费入口 | 亚洲 欧美 综合 | 国产精品一区二区电影 | 午夜天堂精品久久久久 | 在线亚洲欧美 |