A novice learner Dubbo, has this problem when integrating Spring-boot to do Demo.
the service provider can start normally, but the caller failed to start. Multiple attempts are inexplicable and cannot be solved. Passers-by point out the problem.
Let"s release the code
error content
2018-08-05 19:02:26.974 INFO 10060 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with "debug" enabled.
Disconnected from the target VM, address: "127.0.0.1:1956", transport: "socket"
2018-08-05 19:02:27.052 ERROR 10060 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field helloService in cn.mrthree.dubbo.HelloController required a bean of type "cn.mrthree.dubbo.HelloService" that could not be found.
Action:
Consider defining a bean of type "cn.mrthree.dubbo.HelloService" in your configuration.
provider ServiceImpl
import org.springframework.stereotype.Service;
@Service("helloService")
public class HelloServiceImpl implements HelloService {
@Override
public String sayHello(String name) {
return "Hello " + (name == null ? "World" : name);
}
}
provider configuration
srping:
dubbo:
application: -sharp
name: hello-service
registry: -sharp
address: zookeeper://192.168.1.102:2181
protocol: -sharp
name: dubbo
port: 20880
service:
interface: cn.mrthree.dubbo.HelloService
ref: helloService
server:
port: 8880
caller Controller
package cn.mrthree.dubbo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@Autowired
private HelloService helloService;
@GetMapping("hello")
public String hello(@RequestParam(value="name", required = false) String name){
return helloService.sayHello(name);
}
}
caller configuration
srping:
dubbo:
application: -sharp
name: hello-consumer
registry: -sharp
address: zookeeper://192.168.1.102:2181
base-package: cn.mrthree.dubbo
reference:
id: helloService
interface: cn.mrthree.dubbo.HelloService
server:
port: 8881
servlet:
context-path: /dubbo-consumer