SPRINGMVC Dubbo Consumer @Reference Comment is invalid, service layer returns null pointer

Source: Internet
Author: User

since future projects will use Spring boot technology as the theme, these days have tried Springboot+dubbo to complete the layering of business architectures, this article mainly records the Dubbo null pointer problems encountered during SPRINGBOOT construction.

First, we recommend that you have a channel to this problem and take a look at this article

Http://www.oschina.net/question/1011127_144093?fromerr=7pRd3NKv

Although this article does not solve the problem of springboot configuration, but to solve this problem provides the idea, SPRINGBOOT+DUBBO null pointer problem, the main reason:Spring Scan is not recognized at all @Reference , on the same side, the Dubbo scan also does not recognize the spring @Controller , so the sequence of two scans should be arranged, if the controller is first swept, then the controllers are instantiated, and then sweep the Dubbo service, there will be a null pointer.

The following code is provided:

Dubbo-provider.xml: The provider scans the spring framework, completes the spring portion of the scan, and then serves the Dubbo framework, in contrast to the consumer part, scanning the Dubbo service first, then scanning the spring part ~

<mvc:annotation-driven/> <!--consumer app name, used to calculate dependencies, not match criteria, not as provider--<dubbo:application name= "Dubbo-con    Sumer "owner=" programmer "organization=" Dubbox "/> <dubbo:registry address=" zookeeper://127.0.0.1:2181 "/> <dubbo:consumer timeout= "30000"/> <!--<dubbo:reference id= "Demoservice" interface= "Com.dubbo.service.D Emoservice "/>-<dubbo:annotation package=" Com.dubbo.controller "/> <!--convert classes marked @controller annotations to Beans --<context:component-scan base-package= "Com.dubbo.controller"/>

Production test: 53039491

SPRINGMVC Dubbo Consumer @Reference Comment is invalid, service layer returns null pointer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.