How to solve the problem that the client cannot register after adding Spring Security permission verification in Spring Cloud Eureka?
This article shows you how to solve the problem that the client can not register after adding Spring Security permission verification, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Spring Cloud Eureka uses the client when registering after adding Spring Security permission verification
Eureka.client.service-url.defaultZone= http://xiaoming:10010@localhost:8761/eureka/
The client reported an error when registering
Com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute (RetryableEurekaHttpClient.java:112) ~ [eureka-client-1.9.12.jar:1.9.12] at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register (EurekaHttpClientDecorator.java:56) ~ [eureka-client-1.9.12.jar:1.9.12] at com.netflix .discovery.shared.transport.decorator.EurekaHttpClientDecorator $1.execute (EurekaHttpClientDecorator.java:59) ~ [eureka-client-1.9.12.jar:1.9.12] at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute (SessionedEurekaHttpClient.java:77) ~ [eureka-client-1.9.12.jar:1.9.12] at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register (EurekaHttpClientDecorator.java:56) ~ [eureka-client-1 .9.12.jar: 1.9.12] at com.netflix.discovery.DiscoveryClient.register (DiscoveryClient.java:847) ~ [eureka-client-1.9.12.jar:1.9.12] at com.netflix.discovery.InstanceInfoReplicator.run (InstanceInfoReplicator.java:121) ~ [eureka-client-1.9.12.jar:1.9.12] at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511) [na: 1.8.0mm 172] at java.util.concurrent.FutureTask.run (FutureTask.java:266) [na:1.8.0_172] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:180) [na:1.8.0_172] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:293) [na:1.8.0_172] at java.util.concurrent.ThreadPoolExecutor. RunWorker (ThreadPoolExecutor.java:1149) [na:1.8.0_172] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624) [na:1.8.0_172] at java.lang.Thread.run (Thread.java:748) [na:1.8.0_172]
It is found that csrf (cross-site request forgery) check is enabled by default in the version after spring boot 2.x, which leads to an error report.
Solution: add a configuration class to the eureka service project, ignoring the check for / eureka requests
@ EnableWebSecuritypublic class WebSecurityConfig extends WebSecurityConfigurerAdapter {@ Override protected void configure (HttpSecurity http) throws Exception {http.csrf (). IgnoringAntMatchers ("/ eureka/**"); super.configure (http);}} the above content is how to solve the problem that the client cannot register after adding Spring Security permission verification. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.