1.pom
<!--dubbo与zk的组件 start -->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
<!--dubbo与zk的组件 end -->
2.yml
dubbo:
application:
name: your-service-name
registry:
address: zookeeper://127.0.0.1:2181
timeout: '20000'
protocol:
name: dubbo
port: '-1'
monitor:
protocol: registry
consumer:
check: false
3.config:
import com.alibaba.dubbo.config.ConsumerConfig;
import com.alibaba.dubbo.config.ProviderConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author lxr
*/
@Configuration
public class DubboConfig {
@Bean
public ConsumerConfig consumerConfig() {
ConsumerConfig consumerConfig = new ConsumerConfig();
consumerConfig.setCheck(false);
consumerConfig.setTimeout(5000);
return consumerConfig;
}
@Bean
public ProviderConfig providerConfig(){
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setTimeout(30000);
providerConfig.setRetries(0);
return providerConfig;
}
}
4.主启动类注解:
@EnableDubbo
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
public class WarehousingMain {
public static void main(String[] args) {
SpringApplication.run(WarehousingMain.class,args);
}
}
标签:集成,dubbo,springboot,providerConfig,consumerConfig,import,ConsumerConfig,public From: https://www.cnblogs.com/zjfblog/p/17836943.html