FeignClient specified configuration class does not take effect

2.8k Views Asked by At

I'm a novice at Stack Overflow. I really don't know why 'Ask Question' doesn't indicate the location to be formatted. I can only use Blackquote to wrap most non code segments. Maybe Stack Overflow can make questions friendly?

I use Nacos service registration, use Spring LoadBalancer to initiate remote calls with openfeign, I specify a configuration class to specify log output level and load balancing strategy for FeignClient.

I extracted FeignClient and Configuration into separate module commons

// FeignClient Configuration
@Data
@Configuration
@ConfigurationProperties("at999.cloud.commons.feign")
public class FeignConfig{

    private String logging;
    private String rule;

    @Bean
    public Logger.Level level(){
        System.out.println(">> " + logging + " >>");
        switch(String.valueOf(logging)){
            case "FULL":
                return Logger.Level.FULL;
            case "HEADERS":
                return Logger.Level.HEADERS;
            case "BASIC":
                return Logger.Level.BASIC;
            case "NONE":
            case "null":
            default:
                return Logger.Level.NONE;
        }
    }

    @Bean
    public ReactorServiceInstanceLoadBalancer rule(Environment evnt,
            LoadBalancerClientFactory lbcf, NacosDiscoveryProperties ndps)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException,
                          NoSuchMethodException, InvocationTargetException{
        System.out.println(">>> " + rule + " >>>");
        if(rule != null){
            Class.forName(rule).asSubclass(ReactorServiceInstanceLoadBalancer.class);
            String pn = LoadBalancerClientFactory.getName(evnt);
            System.out.println("*** " + pn + " ***");
            ObjectProvider<ServiceInstanceListSupplier> op = lbcf.getLazyProvider(pn, ServiceInstanceListSupplier.class);
            if(rule.endsWith(".NacosLoadBalancer"))
                return new NacosLoadBalancer(op, pn, ndps);
            else{
                Object or = Class.forName(rule).getDeclaredConstructor().newInstance(op, pn);
                if(or instanceof ReactorServiceInstanceLoadBalancer){
                    return ReactorServiceInstanceLoadBalancer.class.cast(or);
                }
            }
        }
        return null;
    }

}

bootstrap.yml

server:
  port: 8080
  servlet:
    context-path: /

spring:
  application:
    name: nacos-client
  profiles:
    active: dev
  cloud:
    nacos:
      config:
        server-addr: at999.eu.org:8848
        file-extension: yaml
      discovery:
        # I use a remote server to run the registry
        server-addr: at999.eu.org:8848
        # I want to use NacosRule to give preference to local cluster
        # I have also deployed the same cluster on the remote server
        cluster-name: CN
        username: nacos
        password: nacos

NacosRule

The same configuration for the service provider

just no content of application.yml and bootstrap.yml cluster-name is US and application.name is user-client

application.yml

spring:
  cloud:
    loadbalancer:
      ribbon:
        enabled: false

loadbalancer:
  client:
    name: ${spring.application.name}

at999:
  cloud:
    commons:
      feign:
        logging: FULL
        rule: com.alibaba.cloud.nacos.loadbalancer.NacosLoadBalancer

Specify configuration properties

// Feign Client
@FeignClient(value="user-client", configuration=FeignConfig.class)
public interface UserClientFeign{

    @GetMapping("/user")
    User getUser();

}

This is the service provider

@GetMapping("/user")
public User getUser(){
    user.setName(user.getName() + "(c)");
    return user;
}

This is the consumer of the service

@Resource
private UserClientFeign userClientFeign;

@GetMapping("/get/user")
public User getUserServiceUser(){
    return userClientFeign.getUser();
}

Consumers import commons modules

commons module spring.factories

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
                                                               \
com.at999.springcloud.nacos.commons.FeignConfiguration

Scanning doesn't seem to work

@ConfigurationPropertiesScan("com.at999.springcloud.nacos.commons.feign.config")
public class FeignConfiguration{

}

This is the commons directory structure

$tree
.
├── main
│   ├── java
│   │   └── com
│   │       └── at999
│   │           └── springcloud
│   │               └── nacos
│   │                   └── commons
│   │                       ├── FeignConfiguration.java
│   │                       ├── feign
│   │                       │   ├── UserClientFeign.java
│   │                       │   └── config
│   │                       │       └── FeignConfig.java
│   │                       │
│   │                       └── pojo
│   │                           └── User.java

consumer main startup class

@SpringBootApplication
@EnableFeignClients(clients=UserClientFeign.class)
public class ApplicationStart{

    public static void main(String[] args) {
        SpringApplication.run(ApplicationStart.class, args);
    }

}

access interface

The first access succeeded because it used the default polling

$curl http://localhost:8080/get/user
[ERROR] 2022-10-21 00:30:48,730 ~ http-nio-8080-exec-3 ~ org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] ~ ?.?:? -- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.RetryableException: Connect timed out executing GET http://user-client/user] with root cause
java.net.SocketTimeoutException: Connect timed out
    at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:543)
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:594)
    at java.base/java.net.Socket.connect(Socket.java:633)
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:178)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:498)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
    at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:246)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:351)
    at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:373)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1309)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1242)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1128)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1057)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1665)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
    at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
    at feign.Client$Default.convertResponse(Client.java:109)
    at feign.Client$Default.execute(Client.java:105)
    at org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing(LoadBalancerUtils.java:56)
    at org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing(LoadBalancerUtils.java:91)
    at org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient.execute(FeignBlockingLoadBalancerClient.java:113)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
    at jdk.proxy2/jdk.proxy2.$Proxy85.getUser(Unknown Source)
    at com.at999.springcloud.nacos.client.controller.TestController.getUserServiceUser(TestController.java:51)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
    at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:485)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
    at com.at999.springcloud.nacos.client.controller.TestController$$EnhancerBySpringCGLIB$$beda0af8.getUserServiceUser(<generated>)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
    at 
    ...

I searched for a day and couldn't find a solution, GitHub traced some source code, but without IDEA debugging, the laptop (a dozen years ago) can only run light linux

I have tried removing FeignConfig's annotation @Configuration

The access interface will only appear 404

FeignClient does not resolve to an accessible ip:port after pulling the service for the first time

$curl http://localhost:8080/get/user
[INFO] 2022-10-21 01:04:26,149 ~ http-nio-8080-exec-1 ~ org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] ~ ?.?:? -- Initializing Spring DispatcherServlet 'dispatcherServlet'
[INFO] 2022-10-21 01:04:26,149 ~ http-nio-8080-exec-1 ~ org.springframework.web.servlet.DispatcherServlet ~ ?.?:? -- Initializing Servlet 'dispatcherServlet'
[INFO] 2022-10-21 01:04:26,152 ~ http-nio-8080-exec-1 ~ org.springframework.web.servlet.DispatcherServlet ~ ?.?:? -- Completed initialization in 3 ms
[INFO] 2022-10-21 01:04:26,697 ~ http-nio-8080-exec-1 ~ com.alibaba.nacos.client.naming ~ ?.?:? -- new ips(2) service: DEFAULT\_GROUP@@nacos-client -> [{"instanceId":"192.168.1.39#8080#CN#DEFAULT\_GROUP@@nacos-client","ip":"192.168.1.39","port":8080,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"CN","serviceName":"DEFAULT\_GROUP@@nacos-client","metadata":{"preserved.register.source":"SPRING\_CLOUD"},"ipDeleteTimeout":30000,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000},{"instanceId":"172.16.0.15#8080#US#DEFAULT\_GROUP@@nacos-client","ip":"172.16.0.15","port":8080,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"US","serviceName":"DEFAULT\_GROUP@@nacos-client","metadata":{"preserved.register.source":"SPRING\_CLOUD"},"ipDeleteTimeout":30000,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000}]
[INFO] 2022-10-21 01:04:26,720 ~ http-nio-8080-exec-1 ~ com.alibaba.nacos.client.naming ~ ?.?:? -- current ips:(2) service: DEFAULT\_GROUP@@nacos-client -> [{"instanceId":"192.168.1.39#8080#CN#DEFAULT\_GROUP@@nacos-client","ip":"192.168.1.39","port":8080,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"CN","serviceName":"DEFAULT\_GROUP@@nacos-client","metadata":{"preserved.register.source":"SPRING\_CLOUD"},"ipDeleteTimeout":30000,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000},{"instanceId":"172.16.0.15#8080#US#DEFAULT\_GROUP@@nacos-client","ip":"172.16.0.15","port":8080,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"US","serviceName":"DEFAULT\_GROUP@@nacos-client","metadata":{"preserved.register.source":"SPRING\_CLOUD"},"ipDeleteTimeout":30000,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000}]
[ERROR] 2022-10-21 01:04:27,034 ~ http-nio-8080-exec-1 ~ org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] ~ ?.?:? -- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException$NotFound: [404] during [GET] to [http://user-client/user] [UserClientFeign#getUser()]: [{"timestamp":"2022-10-20T17:04:26.853+00:00","status":404,"error":"Not Found","path":"/user"}]] with root cause
feign.FeignException$NotFound: [404] during [GET] to [http://user-client/user] [UserClientFeign#getUser()]: [{"timestamp":"2022-10-20T17:04:26.853+00:00","status":404,"error":"Not Found","path":"/user"}]
    at feign.FeignException.clientErrorStatus(FeignException.java:219)
    at feign.FeignException.errorStatus(FeignException.java:194)
    at feign.FeignException.errorStatus(FeignException.java:185)
    at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)
    at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:96)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
    at jdk.proxy2/jdk.proxy2.$Proxy85.getUser(Unknown Source)
    at com.at999.springcloud.nacos.client.controller.TestController.getUserServiceUser(TestController.java:51)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
    at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:485)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
    at com.at999.springcloud.nacos.client.controller.TestController$$EnhancerBySpringCGLIB$$c1eb0cb4.getUserServiceUser(<generated>)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)
{"timestamp":"2022-10-20T17:04:27.038+00:00","status":500,"error":"Internal Server Error","path":"/get/user"}⏎           

I tried to delete the loadbalancer.client.name attribute in application.yml, so that the Bean rule in FeignConfig cannot get the name value when creating NacosLoadBalancer at startup

Accessing the interface he will have the following error

$curl http://localhost:8080/get/user
[INFO] 2022-10-21 01:25:33,098 ~ http-nio-8080-exec-1 ~ org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] ~ ?.?:? -- Initializing Spring DispatcherServlet 'dispatcherServlet'
[INFO] 2022-10-21 01:25:33,098 ~ http-nio-8080-exec-1 ~ org.springframework.web.servlet.DispatcherServlet ~ ?.?:? -- Initializing Servlet 'dispatcherServlet'
[INFO] 2022-10-21 01:25:33,104 ~ http-nio-8080-exec-1 ~ org.springframework.web.servlet.DispatcherServlet ~ ?.?:? -- Completed initialization in 6 ms
[ERROR] 2022-10-21 01:25:33,871 ~ http-nio-8080-exec-1 ~ org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] ~ ?.?:? -- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null] with root cause
java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null
    at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
    at java.base/java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:964)
    at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:102)
    at org.springframework.cloud.context.named.NamedContextFactory.getProvider(NamedContextFactory.java:161)
    at org.springframework.cloud.context.named.ClientFactoryObjectProvider.delegate(ClientFactoryObjectProvider.java:115)
    at org.springframework.cloud.context.named.ClientFactoryObjectProvider.getIfAvailable(ClientFactoryObjectProvider.java:64)
    at com.alibaba.cloud.nacos.loadbalancer.NacosLoadBalancer.choose(NacosLoadBalancer.java:68)
    at com.alibaba.cloud.nacos.loadbalancer.NacosLoadBalancer.choose(NacosLoadBalancer.java:47)
    at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.choose(BlockingLoadBalancerClient.java:155)
    at org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient.execute(FeignBlockingLoadBalancerClient.java:97)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
    at jdk.proxy2/jdk.proxy2.$Proxy85.getUser(Unknown Source)
    at com.at999.springcloud.nacos.client.controller.TestController.getUserServiceUser(TestController.java:51)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
    at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:485)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
    at com.at999.springcloud.nacos.client.controller.TestController$$EnhancerBySpringCGLIB$$88a31f37.getUserServiceUser(<generated>)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1732)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)
{"timestamp":"2022-10-20T17:25:34.013+00:00","status":500,"error":"Internal Server Error","path":"/get/user"}⏎  

I know that in spring.cloud.nacos.loadbalancer.enabled=true it will use NacosRule

I just want to know where I went wrong

0

There are 0 best solutions below