Home > Java > javaTutorial > body text

Detailed explanation of annotated Dubbo service configuration examples

零下一度
Release: 2017-06-28 09:11:00
Original
2568 people have browsed it

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:
1. Service provider
1. Add Dubbo annotation scanning in Dubbo configuration file
<!-- 开启dubbo注解支持 -->
<!-- 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前ApplicationContext中所有的类 -->
<dubbo:annotation package="com.bounter" />
Copy after login
Copy after login
2. Add Dubbo Service annotation to the Service implementation class
import com.alibaba.dubbo.config.annotation.Service;

@Servicepublic class DubboServiceImpl implements DubboService {
}
Copy after login
2. Service consumer
1. Add Dubbo annotation scanning in Dubbo configuration file (same as service provider)
<!-- 开启dubbo注解支持 -->
<!-- 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前ApplicationContext中所有的类 -->
<dubbo:annotation package="com.bounter" />
Copy after login
Copy after login
2. Introduce dubbo configuration into Spring MVC configuration to solve the problem of dubbo annotation incompatibility ( is very important, otherwise it is introduced into the controller The service will report a null pointer)
<!-- 引入dubbo配置,解决dubbo注解不兼容问题 -->
<import resource="classpath:spring-dubbo.xml"/>
Copy after login
3. After the Dubbo service is introduced into the controller, it can be used
@Referenceprivate DubboService dubboService;
Copy after login

The above is the detailed content of Detailed explanation of annotated Dubbo service configuration examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!