头图

problem

  • @Autowired in the Controller layer to inject Service , it prompts Bean without
  • After using the @Component injection in the Service interface, the startup project problem prompt:

    The web application [ROOT] appears to have started a thread named [DubboClientReconnectTimer-thread-2] but has failed to stop it.
    This is very likely to create a memory leak

    reason

  • prompts that there is no Service in Bean:

    • Because Service injected into the Spring container, it can be through 161d06579da85d @Component or @Service
  • uses annotations in the Service to inject into the container, the startup project will report an error :

    • Because the Service interface is injected, two Bean
    • injected into the Service interface, and the subclasses that implement the Service interface will also be injected into the container, so it will cause Dubbo repetitive thread error

      Solution

  • On the implementation class ServiceImpl Service , use @Component or @Service annotation to Service into the Spring container
  • If you are using Dubbo's SpringBoot project, you can use the following annotations in the Service implementation class

    @com.alibaba.dubbo.config.annotation.Service
    @org.springframework.stereotype.Service
  • Note: To inject the Service implementation class into the container, not the Service interface

    Summarize

  • Spring container injection rules

攻城狮Chova
67 声望8 粉丝

一位有自我修养的攻城狮。