https://github.com/apache/incubator-dubbo-spring-boot-project
当采用properties方式时,可以用下方的注解
1.pom
com.alibaba dubbo 2.6.2 org.apache.zookeeper zookeeper 3.4.11 org.slf4j slf4j-api org.apache.curator curator-framework 2.12.0 org.springframework.boot spring-boot-starter org.apache.dubbo dubbo-spring-boot-starter 2.7.0
2.yml 初步配置
dubbo: application: name: bootprovide registry: address: 127.0.0.1:2181 protocol: zookeeper protocol: name: dubbo port: 20880
3.service (要用dubbo包的) ==>> 暴露服务
4.启动类 加上 @EnableDubbo
package com.abc;import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@EnableDubbo@SpringBootApplicationpublic class BootProvideApplication { public static void main(String[] args) { SpringApplication.run(BootProvideApplication.class, args); }}
二、消费者
@Reference 自动注入
@Reference 注入远程服务对象 和@Autowired作用相似