今天解决了Eureka集群部署下且开启安全认证问题,不知道是我的版本太新还是什么原因导致,之前boot使用2.1.18版本,cloud是G版本正常。
- 关键报错信息如下(其实报错信息前后还有一大堆):
2021-03-31 21:31:53.788 ERROR 51120 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://eureka:ebsEureka2021@peer2:7002/eureka/}
javax.ws.rs.WebApplicationException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Root name 'timestamp' does not match expected ('instance') for type [simple type, class com.netflix.appinfo.InstanceInfo]
at [Source: (com.sun.jersey.client.apache4.ApacheHttpClient4Handler$HttpClientResponseInputStream); line: 1, column: 2] (through reference chain: com.netflix.appinfo.InstanceInfo["timestamp"])
at com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110) ~[eureka-client-1.9.13.jar:1.9.13]
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586) ~[jersey-client-1.19.1.jar:1.19.1]
- 寻思很久,一开始一直以为是Eureka参数
eureka.client.serviceUrl.defaultZone
问题 - 终于根据 Root name 'timestamp' 异常找到了解决方案
/**
* @author qinchen
* @date 2021/3/31 9:22 下午
* 向未来的自己致敬
* 描述:解决Eureka集群部署下且开启安全认证问题
*/
@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable(); //关闭csrf
super.configure(http); //开启认证
}
}