springboot集成dubbo,如果在对应的service实现类添加springcache缓存实现,service会注册zookeeper失败
1.引用的springboot的dubbo集成jar替换为阿里的jar包
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
2.在springboot的启动类上添加注解@EnableDubbo
package com.springboot.test.iservice;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
@MapperScan("com.springboot.test.mapper")
@SpringBootApplication
@EnableDubbo
@EnableCaching
public class SpringBootIServiceImplApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootIServiceImplApplication.class, args);
}
}
3.配置application.properties
#Dubbo 服务提供者配置
dubbo.application.name=dubbo-spring-boot-starter
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
dubbo.scan.base-packages=com.springboot.test.iservice
|
|