dubbo
dubbo copied to clipboard
使用 apollo 当配置中心,dubbo.application.name的 placeholder 未解析
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
- [x] I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.7.3-SNAPSHOT
- Operating System version: mac catline
- Java version: 1.8
Steps to reproduce this issue
使用 apollo 当配置中心,dubbo配置放在默认的dubbo.properties namespace bootstrap.yml中的配置
spring:
application:
name: mls-biz-company
apollo:
bootstrap:
enabled: true
namespaces: application,dubbo
apollo dubbo.properties 中的配置
dubbo.registry-cache = ${java.io.tmpdir:-/tmp}
dubbo.application.name = ${spring.application.name}
dubbo.protocol.name = dubbo
dubbo.protocol.port = ${server.dubbo-port}
dubbo.scan.base-packages = com.lianjia.mls.company
dubbo.config-center.address = apollo://dev.config.apollo.ke.com
dubbo.metadata-report.group = /home/likemoon/dubbo
dubbo.metadata-report.username = myname
dubbo.metadata-report.address = zookeeper://zk01-test.likemoon.com:2181
dubbo.metadata-report.password = mypasswd
dubbo.registries.alliance.address = ...
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
What do you expected from the above steps? 启动的时候能正确解析dubbo.application.name 的 placeholder : ${spring.application.name}
Actual Result
What actually happens? 服务启动过程报错
If there is an exception, please attach the exception trace:
[DUBBO] Failed to override , dubbo version: 2.7.3-SNAPSHOT, current host: 10.33.69.254
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.dubbo.config.AbstractConfig.refresh(AbstractConfig.java:569)
at org.apache.dubbo.config.ApplicationConfig.refresh(ApplicationConfig.java:387)
at java.util.Optional.ifPresent(Optional.java:159)
at org.apache.dubbo.config.context.ConfigManager.refreshAll(ConfigManager.java:302)
at org.apache.dubbo.config.AbstractInterfaceConfig.startConfigCenter(AbstractInterfaceConfig.java:281)
at org.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:285)
at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:358)
at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:327)
at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:105)
at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:51)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.lianjia.mls.company.Application.main(Application.java:20)
Caused by: java.lang.IllegalStateException: Invalid name="${spring.application.name}" contains illegal character, only digit, letter, '-', '_' or '.' is legal.
at org.apache.dubbo.config.AbstractConfig.checkProperty(AbstractConfig.java:387)
at org.apache.dubbo.config.AbstractConfig.checkName(AbstractConfig.java:345)
at org.apache.dubbo.config.ApplicationConfig.setName(ApplicationConfig.java:163)
... 29 common frames omitted
看代码从配置中心取到之后未处理 placeholder 在refresh 过程总反射调用org.apache.dubbo.config.ApplicationConfig.setName(java.lang.String)过程中报如上的异常
你这是提前初始化了,导致占位符没有被替换
No feedback for a long time, please close the issue temporarily. If there is still a problem, you can reopen it.