BladeX框架改造Apollo配置中心适配去掉Nacos咨询

Blade 未结 2 142
627588637
627588637 剑圣 2024-07-22 13:35

一、该问题的重现步骤是什么?

 1.SpringBoot原生框架,启动读取Apollo配置

企业截图_17216244719143.png

企业截图_17216243666514.png


2. BladeX-Biz样例工程blade-apollo,启动读取Apollo配置

企业截图_1721623804676.png


企业截图_17216238747330.png

编写测试ApolloController,测试API调用读取blade-dev.yaml配置中的数据库驱动类和连接

企业截图_1721624177801.png

企业截图_1721624056839.png


3. BladeX企业版gateway和auth工程改造Apollo配置读取,启动时报错

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Bean method 'init' must not be declared as void; change the method's return type or its annotation.

企业截图_17216254112869.png


4 BladeX企业版common工程改造Apollo配置读取,启动时动态读取自定义apollo配置类属性

企业截图_17216259264795.png


5 BladeX企业版common工程改造Apollo配置读取,启动时动态读取自定义apollo配置类属性

企业截图_17216262369552.png


二、你期待的结果是什么?实际看到的又是什么?

期望:GateWayApplication网关应用读取Apollo配置中心,其他应用启动后能正常读取Apollo配置中心

实际:参考BladeX-Biz样例工程blade-apollo,无法支持具体改写GateWay、Common以及其他微服务工程的方式


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

BladeX企业版,4.1.0.RELEASE,Windows开发环境


四、请提供详细的错误堆栈信息,这很重要。



五、若有更多详细信息,请在下面提供。


2条回答
  • 2024-07-22 13:50

    不要用springboot测试,用原生的springcloud测试,测试每个工程加载yml的数据库配置。另外nacos本身的配置文件都要删掉防止重名冲突,然后把nacosconfig的配置删掉。

    如果你原生的cloud工程可以bladex不行,就把原生cloud工程发到我们邮箱:bladejava@qq.com

    0 讨论(0)
  • 2024-07-22 15:08

    目前读取Apollo配置中心问题采用以下方式临时解决,需要帮忙看下是否有其他影响

    1、API方式读取YAML

    BladeDevYmlConfig {
    
    
       ()
       Config 
       String () {
          System..println(+ getDriverClassName())System..println(+ getDatasourceUrl())getDriverClassName()}
    }

    2、新建BladeCustomizeApplication重写BladeX 应用启动类,适配Apollo配置中心

    setDefaultProperties方法改为调用setApolloProperties方法

    Properties defaultProperties = setApolloProperties(appName, profile); // 设置默认的一些属性

    SpringApplicationBuilder (String appNameClass<?> sourceSpringApplicationBuilder builderString... args) {
       Assert.(appName)ConfigurableEnvironment environment = (args)List<String> activeProfileList = (environment)String profile = (activeProfileList)(builder == ) { builder = SpringApplicationBuilder(source)}
       builder.profiles(profile)(appNameprofile)Properties defaultProperties = (appNameprofile)builder.properties(defaultProperties)(builderappNameprofile)builder}


    Properties (String appNameString profile) {
       Properties defaultProperties = Properties()defaultProperties.setProperty()defaultProperties.setProperty()defaultProperties.setProperty()defaultProperties}


    作者追问:2024-07-22 15:37

    没什么问题,这里就是需要把nacos的默认配置删掉改成适配apollo的

    作者追问:2024-07-22 15:52

    没什么问题,这里就是需要把nacos的默认配置删掉改成适配apollo的

    0 讨论(0)
提交回复