apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.39k stars 26.41k forks source link

混合配置导致的Invalid name="org.apache.dubbo.config.ApplicationConfig#0"问题 #6202

Open sourirer opened 4 years ago

sourirer commented 4 years ago

Environment

Steps to reproduce this issue

  1. 使用java配置的方式配置config类: @Bean public ApplicationConfig applicationConfig(@Qualifier("registryConfig") RegistryConfig registryConfig, @Qualifier("monitorConfig") MonitorConfig monitorConfig) { ApplicationConfig applicationConfig = new ApplicationConfig(); applicationConfig.setName("balance-consumer"); applicationConfig.setMonitor(monitorConfig); return applicationConfig; }
  2. 在environment配置-Ddubbo.application.owner=xxx或者在springboot的application.properties中不配置dubbo.application.id或者dubbo.application.name。
  3. 正常启动。

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

What do you expected from the above steps? 正常启动。

Actual Result

What actually happens? 抛出异常: Caused by: java.lang.IllegalStateException: Invalid name="org.apache.dubbo.config.ApplicationConfig#0" contains illegal character, only digit, letter, '-', '_' or '.' is legal

已经check过其他几个相关的issue,里面都是没有配置对应的name和id导致。 此issue关注点为,在使用java配置了applicationConfig后,如果在其他位置有dubbo.application开头的配置,则会额外由spring生成新的applicationConfig,导致以上异常。

尝试过issue中建议的增加dubbo.application.name或者id,则抛出 Duplicate application configs 异常。

问题是由于dubbo.application触发的applicationConfig和直接配置的applicationConfig不是同一个实例引起的,建议在dubbo.application和java方式配置的applicationConfig之间设定优先级。

kimmy-wang commented 4 years ago

same issue

yuxiao97 commented 4 years ago

same issue dubbo-spring-boot-starter:2.7.7

kylixs commented 3 years ago

@sourirer Can you provide an example project? For example, put it in a github project.

shlsky commented 3 years ago

same issue

lennon1994 commented 3 years ago

same issue