code:
  @EnableDubbo
@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

#dubbo.application.name=rest-consumer

#dubbo.protocols.rest.name = rest
#dubbo.protocols.rest.port = 8889
#dubbo.protocols.rest.server=tomcat
#dubbo.registry.address=zookeeper://127.0.0.1:2181


@RestController
@RequestMapping(path = "/template")
public class IndexController {

    @Reference
    AnotherUserRestService anotherUserRestService;
    @RequestMapping(value = "/getData", method = RequestMethod.GET)
    public String index() {
        System.out.println(anotherUserRestService.getUser(1L));
        return "index";
    }

anotherUserRestService is null.

it seems that springboot component scan and dubbo reference bean,  are in 
different context.  From log,
i can see that dubbo:reference,   proxy object is already created. 
However, below object reference is always null.
    @Reference
    AnotherUserRestService anotherUserRestService;



Solution:

@ImportResource("classpath:rest-consumer.xml")
@EnableDubbo
@SpringBootApplication

rest-consumer.xml

dubbo:application name="rest-consumer" owner="programmer" organization="dubbo"/>

    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>

    <dubbo:reference id="anotherUserRestService"
                     
interface="org.apache.dubbo.samples.rest.api.facade.AnotherUserRestService"/>
and then it works.

the protocol is rest.
Does any solution that we can use annotation to get the proxy object ?


[ Full content available at: 
https://github.com/apache/incubator-dubbo-spring-boot-project/issues/415 ]
This message was relayed via gitbox.apache.org for 
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to