Get the App
SLTechnology News&Howtos  ›  Servers  › 

Annotation-based Dubbo service configuration method (example explanation)

Shulou Source: shulou.com Published: 2022-06-02 01:11:47 11月15日 Update

Annotation-based Dubbo service configuration can greatly reduce the amount of Service configuration in the dubbo xml configuration file, the main steps are as follows:

I. Service provider

1. Add Dubbo annotation scan to Dubbo configuration file

Add Dubbo Service annotations to the 2.Service implementation class

Import com.alibaba.dubbo.config.annotation.Service;@Servicepublic class DubboServiceImpl implements DubboService {}

II. Service consumers

1. Add Dubbo annotation scan to Dubbo configuration file (same as service provider)

Introduce dubbo configuration into 2.Spring MVC configuration to solve the problem of incompatibility of dubbo annotations (it is critical, otherwise the introduction of services in the controller will report null pointers)

3. Once the Dubbo service is introduced into the controller, you can use the

@ Referenceprivate DubboService dubboService

The above annotation-based Dubbo service configuration method (example explanation) is all the content shared by the editor to you. I hope I can give you a reference and support it.

Tags: Configuration service annotation file service configuration supplier controller control instance method key content that is pointer step problem report reference support consumption Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Xiaomi Linux NVidia