问答详情
源自:-

在application.properties文件中怎么配置rest协议跟dubbo协议?

spring.dubbo.scan=com.imooc.server
spring.dubbo.application.name=provider
#dubbo协议
spring.dubbo.registry.address=zookeeper://127.0.0.1:2181
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20903

#dubbo支持的http REST api 配置
#spring.dubbo.protocol.name=rest
#spring.dubbo.protocol.port=9013
#spring.dubbo.protocol.server=tomcat


放开rest协议,启动会报错,网上有人说在spring的配置文件中不能同时配置多个协议,需要使用api方式配置

@Configuration
public class RestConfig {
    @Bean("dubbo")
    public ProtocolConfig dubboProtocolConfig() {
        ProtocolConfig protocolConfig = new ProtocolConfig();
        protocolConfig.setName("dubbo");
        protocolConfig.setPort(20903);
        protocolConfig.setServer(null);
        return protocolConfig;
    }

//    @Bean("rest")
//    public ProtocolConfig restProtocolConfig() {
//        ProtocolConfig protocolConfig = new ProtocolConfig();
//        protocolConfig.setName("rest");
//        protocolConfig.setPort(9013);
//        protocolConfig.setId("rest");
//        protocolConfig.setServer("tomcat");
//        return protocolConfig;
//    }
}

这样启动也会报错

提问者:宝慕林2471623 2019-05-12 19:35

个回答