Reasons and solutions for the failure of dubbo annotation to expose the interface

1. @Service annotation package error

The correct reference address of @Service is

import com.alibaba.dubbo.config.annotation.Service;

2. There is a transaction annotation @Transactional in the service layer

When the springmvc framework scans the package and finds the @Transactional annotation, it will generate a proxy class and manage this class. When the dubbo interface is exposed, the proxy class will be scanned instead of the original class, because the proxy class There is no inheritance of the @Service annotation, so there is no @Service annotation when scanning this class, so the interface will not be exposed.

Solution:

The easiest way is to expose the interface class to be exposed directly in the configuration file, for example:

<!-- Implement remote service like local service-->
<bean id="xxxService" class="com.xxx.XxxServiceImpl" /> 
<!-- Add exposed remote service configuration-->

<dubbo:service interface=“com.xxx.XxxService” ref=“xxxService” />


If you still need to know about the dubbo problem, you can check the official documentation

The official Chinese document address of dubbo is: http://dubbo.io/books/dubbo-user-book/

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325757321&siteId=291194637