Originally posted by @beiwei30 in #2695 (comment)
Environment
Dubbo version: 2.6.2
Operating System version: mac
Java version: 1.8
配置如下
protocols
protocol1:
name: dubbo
id: dubbo
status: server
protocol2:
id: rest
name: rest
status: server
server: tomcat
contextpath: api/swift/v1
extension: com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter
##服务注释
@service(
version = "${demo.service.version}",
application = "${dubbo.application.id}",
registry = "${dubbo.registry.id}",
protocol = "dubbo"
)
public class DefaultDemoService implements DemoService{
……………………
}
问题: 无法指定服务的协议类型。
建议:
service注解标明协议类型,则是指定类型暴露,否则按照配置协议类型暴露
工程启动错误提示如下:
===2018-11-09 15:44:00.450 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor Line:85 - The properties of bean [name : protocol1] have been binding by prefix of configuration properties : dubbo.protocols.protocol1
===2018-11-09 15:44:00.456 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor Line:85 - The properties of bean [name : protocol2] have been binding by prefix of configuration properties : dubbo.protocols.protocol2
===2018-11-09 15:44:01.194 INFO org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer Line:57 - LiveReload server is running on port 35729
===2018-11-09 15:44:01.322 WARN org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext Line:558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ServiceBean:defaultDemoService:com.swift.boot.dubbo.demo.api.DemoService:${demo.service.version}': Cannot resolve reference to bean 'dubbo' while setting bean property 'protocols' with key [0]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dubbo' available
===2018-11-09 15:44:01.329 INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter Line:451 - Unregistering JMX-exposed beans on shutdown
===2018-11-09 15:44:01.445 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor Line:251 - class com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
===2018-11-09 15:44:01.450 INFO org.apache.catalina.core.StandardService Line:180 - Stopping service [Tomcat]
Originally posted by @beiwei30 in #2695 (comment)
Environment
Dubbo version: 2.6.2
Operating System version: mac
Java version: 1.8
配置如下
protocols
protocol1:
name: dubbo
id: dubbo
status: server
protocol2:
id: rest
name: rest
status: server
server: tomcat
contextpath: api/swift/v1
extension: com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter
##服务注释
问题: 无法指定服务的协议类型。
建议:
service注解标明协议类型,则是指定类型暴露,否则按照配置协议类型暴露
工程启动错误提示如下:
===2018-11-09 15:44:00.450 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor Line:85 - The properties of bean [name : protocol1] have been binding by prefix of configuration properties : dubbo.protocols.protocol1
===2018-11-09 15:44:00.456 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor Line:85 - The properties of bean [name : protocol2] have been binding by prefix of configuration properties : dubbo.protocols.protocol2
===2018-11-09 15:44:01.194 INFO org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer Line:57 - LiveReload server is running on port 35729
===2018-11-09 15:44:01.322 WARN org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext Line:558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ServiceBean:defaultDemoService:com.swift.boot.dubbo.demo.api.DemoService:${demo.service.version}': Cannot resolve reference to bean 'dubbo' while setting bean property 'protocols' with key [0]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dubbo' available
===2018-11-09 15:44:01.329 INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter Line:451 - Unregistering JMX-exposed beans on shutdown
===2018-11-09 15:44:01.445 INFO com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor Line:251 - class com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
===2018-11-09 15:44:01.450 INFO org.apache.catalina.core.StandardService Line:180 - Stopping service [Tomcat]