弱弱的问一下,
nutz + dubbo 获取不到消费者,代码如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="hello-world-app" />
<!-- <dubbo:registry address="multicast://224.0.0.0:9999" /> -->
<dubbo:registry address="zookeeper://127.0.0.1:2181" />
<dubbo:protocol name="dubbo" port="20880" />
<!-- <dubbo:protocol name="injvm"></dubbo:protocol> -->
<dubbo:service interface="com.test.dub.service.DemoService" ref="demoServiceLocal" />
<dubbo:reference id="demoServiceRemote" interface="com.test.dub.service.DemoService" />
</beans>
package com.test.dub.service;
public interface DemoService {
String hi(String name);
}
package com.test.dub.service;
import org.nutz.ioc.loader.annotation.IocBean;
import com.alibaba.dubbo.config.annotation.Service;
@IocBean(name="demoServiceLocal")
@Service
public class DemoServiceImpl implements DemoService {
public DemoServiceImpl() {}
public String hi(String name) {
System.out.println("hi, everyone");
return "hi,"+name;
}
}
package com.test.dub.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import com.alibaba.dubbo.config.annotation.Reference;
import com.test.dub.service.DemoService;
@IocBean
public class TestAction {
// @Inject
@Reference(consumer="demoServiceRemote")
protected DemoService demoService;
@At
public void home(HttpServletRequest request, HttpServletResponse response) {
System.out.println(demoService.hi("hunter"));
}
public void setDemoService(DemoService demoService) {
this.demoService = demoService;
}
}
-------------------------------------------------------------------
// @Inject
@Reference(consumer="demoServiceRemote")
protected DemoService demoService;
这个必须要用@Inject注入么?