apache / dubbo-spring-boot-project

Spring Boot Project for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
5.41k stars 1.88k forks source link

协议配置default(protocol.default=true)不起作用 #311

Closed Lzw2016 closed 5 years ago

Lzw2016 commented 5 years ago

配置如下

dubbo:
  application: #------------------------------------------------------ dubbo应用配置
    id: SpringDubboProvider
    name: SpringDubboProvider
  registry: #----------------------------------------------------------- 注册中心配置
    id: zk-registry
    protocol: zookeeper
    address: 127.0.0.1:2181
    default: true
    client: curator
    transporter: netty
    check: true
    register: true
    subscribe: true
    dynamic: true
    group: dev-group
  protocol: #-------------------------------------------------------------- 协议配置
    id: dubbo
    name: dubbo
    port: 20881
    default: true

设置服务暴露端口 20881

版本如下

       <dependency>
                <groupId>com.alibaba.boot</groupId>
                <artifactId>dubbo-spring-boot-starter</artifactId>
                <version>0.2.0</version>
            </dependency>

代码如下

@Service
public class DefaultDemoService implements DemoService {

    @Override
    public String sayHello(String name) {
        return "Hello, " + name + " (from Spring Boot)";
    }
}

但是服务启动后暴露端口依然是20880, 不想每个服务都用 @Service(protocol = {"dubbo"})指定协议

mercyblitz commented 5 years ago

Please update dependencies in your Maven pom.xml, like this:

<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

<!-- Dubbo -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.5</version>
</dependency>
<!-- Spring Context Extras -->
<dependency>
    <groupId>com.alibaba.spring</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>1.0.2</version>
</dependency>