Blade框架如何配置多数据源

Blade 已结 2 1529
xmrdx
xmrdx 剑圣 2020-10-22 16:36

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

1. 根据https://mybatis.plus/guide/dynamic-datasource.html配置多数据源

2. 启动本地程序


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

期待结果是正常支持多数据源

实际显示配置有误,无法启动程序


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

  BladeX boot版本, 2.6.0.RELEASE,win10本地开发环境


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

Connected to the target VM, address: '127.0.0.1:53899', transport: 'socket'

16:20:18.380 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in PropertySource 'systemProperties' with value of type String

16:20:18.394 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles [dev]

----启动中,读取到的环境变量:[dev],jar地址:[/E:/works/rdx/projects/airportSecurity/code/trunk/airport-security-service/target/classes/]----

                   ______  _             _       ___   ___

                   | ___ \| |           | |      \  \ /  /

                   | |_/ /| |  __ _   __| |  ___  \  V  /

                   | ___ \| | / _` | / _` | / _ \   > <

                   | |_/ /| || (_| || (_| ||  __/ /  .  \

                   \____/ |_| \__,_| \__,_| \___|/__/ \__\


:: BladeX 2.6.0.RELEASE :: airport-security-service:dev :: Running SpringBoot 2.1.16.RELEASE :: 


2020-10-22 16:20:20.471  INFO 6720 --- [           main] org.springblade.Application              : The following profiles are active: dev

2020-10-22 16:20:22.335  INFO 6720 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!

2020-10-22 16:20:22.337  INFO 6720 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.

2020-10-22 16:20:22.550  INFO 6720 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 198ms. Found 0 Redis repository interfaces.

2020-10-22 16:20:22.919  WARN 6720 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[org.springblade]' package. Please check your configuration.

2020-10-22 16:20:23.103  INFO 6720 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=539f2b0f-3896-3c36-af44-72d763a7eab4

2020-10-22 16:20:23.107  INFO 6720 --- [           main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor init.

2020-10-22 16:20:23.108  INFO 6720 --- [           main] s.c.l.p.BladePropertySourcePostProcessor : BladePropertySourcePostProcessor process @BladePropertySource bean.

2020-10-22 16:20:23.858  WARN 6720 --- [           main] io.undertow.websockets.jsr               : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used

2020-10-22 16:20:23.891  INFO 6720 --- [           main] io.undertow.servlet                      : Initializing Spring embedded WebApplicationContext

2020-10-22 16:20:23.891  INFO 6720 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3404 ms

2020-10-22 16:20:24.178  INFO 6720 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource

2020-10-22 16:20:24.264  WARN 6720 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'workController' defined in file [E:\works\rdx\projects\airportSecurity\code\trunk\airport-security-service\target\classes\org\springblade\flow\business\controller\WorkController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'taskServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'taskServiceBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration$AlreadyInitializedAppEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.flowable.spring.boot.app.AppEngineServicesAutoConfiguration': Unsatisfied dependency expressed through method 'setEngineConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processAppEngineConfigurationConfigurer' defined in class path resource [org/flowable/spring/boot/ProcessEngineAutoConfiguration$ProcessEngineAppConfiguration.class]: Unsatisfied dependency expressed through method 'processAppEngineConfigurationConfigurer' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngineConfigurator' defined in class path resource [org/flowable/spring/boot/ProcessEngineAutoConfiguration$ProcessEngineAppConfiguration.class]: Unsatisfied dependency expressed through method 'processEngineConfigurator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/flowable/spring/boot/ProcessEngineAutoConfiguration.class]: Unsatisfied dependency expressed through method 'springProcessEngineConfiguration' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine suitable jdbc url

2020-10-22 16:20:24.272  INFO 6720 --- [           main] ConditionEvaluationReportLoggingListener : 


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2020-10-22 16:20:24.275 ERROR 6720 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.


Reason: Failed to determine suitable jdbc url



Action:


Consider the following:

If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.

If you have database settings to be loaded from a particular profile you may need to activate it (the profiles dev are currently active).


Disconnected from the target VM, address: '127.0.0.1:53899', transport: 'socket'


Process finished with exit code 1


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

pom.xml加入多数据源支持:

RP3[8{SW2KM7WBG0B[VCN}7.png

application.yml配置部分:

9E9@Z3RMP9RN`79H]IQBTBK.png

2条回答
  •  admin
    admin (最佳回答者)
    2020-10-23 12:13

    多数据源参考bladex-biz的blade-demo工程即可

    image.png

    0 讨论(1)
  • 2020-10-23 14:42

    G}KU$K0BT58T(OLH3`WUP{8.png

    系统默认关闭了多数据源,如上参数开启就ok了。

    5 讨论(0)
提交回复