主题:springboot双数据源报错

ko889910 2019年03月06日 97

1.错误日志

11:17:19.918 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []11:17:19.925 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]11:17:19.926 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/ko889910/eclipse-workspace/dataModel/target/classes/]  .   ____          _            __ _ _ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )  '  |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot ::             (v2.0.0.M7)2019-03-06 11:17:20.484  INFO 3228 --- [  restartedMain] c.lk.rulegenerate.datamodel.Application  : Starting Application on DESKTOP-SRLI51N with PID 3228 (C:\Users\ko889910\eclipse-workspace\dataModel\target\classes started by ko889910 in C:\Users\ko889910\eclipse-workspace\dataModel)2019-03-06 11:17:20.484  INFO 3228 --- [  restartedMain] c.lk.rulegenerate.datamodel.Application  : No active profile set, falling back to default profiles: default2019-03-06 11:17:20.594  INFO 3228 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1e000c7e: startup date [Wed Mar 06 11:17:20 CST 2019]; root of context hierarchy2019-03-06 11:17:24.911  INFO 3228 --- [  restartedMain] o.h.v.i.engine.ValidatorFactoryImpl      : HV000238: Temporal validation tolerance set to 0.2019-03-06 11:17:26.528  INFO 3228 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)2019-03-06 11:17:26.557  INFO 3228 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]2019-03-06 11:17:26.557  INFO 3228 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.232019-03-06 11:17:26.597  INFO 3228 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.6.5].2019-03-06 11:17:26.597  INFO 3228 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].2019-03-06 11:17:26.597  INFO 3228 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]2019-03-06 11:17:26.607  INFO 3228 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1a  20 Nov 2018]2019-03-06 11:17:27.357  INFO 3228 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext2019-03-06 11:17:27.367  INFO 3228 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 6773 ms2019-03-06 11:17:28.157  INFO 3228 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]2019-03-06 11:17:28.172  INFO 3228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]2019-03-06 11:17:28.172  INFO 3228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]2019-03-06 11:17:28.172  INFO 3228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]2019-03-06 11:17:28.172  INFO 3228 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]2019-03-06 11:17:28.312  WARN 3228 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'mainService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainServiceImpl': Unsatisfied dependency expressed through field 'mainModelDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainModelDao' defined in file [C:\Users\ko889910\eclipse-workspace\dataModel\target\classes\com\lk\rulegenerate\datamodel\dao\MainModelDao.class]: Cannot resolve reference to bean 'sqlManagerFactoryBean' while setting bean property 'sqlManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlManagerFactoryBean' defined in class path resource [com/ibeetl/starter/BeetlSqlConfig.class]: Unsatisfied dependency expressed through method 'getSqlManagerFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'beetlSqlDataSource' defined in class path resource [com/ibeetl/starter/BeetlSqlConfig.class]: Unsatisfied dependency expressed through method 'beetlSqlDataSource' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found 2: oracle,mysql2019-03-06 11:17:28.332  INFO 3228 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]2019-03-06 11:17:28.502  INFO 3228 --- [  restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-03-06 11:17:28.512 ERROR 3228 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of method beetlSqlDataSource in com.ibeetl.starter.BeetlSqlConfig required a single bean, but 2 were found:    - oracle: defined by method 'datasource' in class path resource [com/lk/rulegenerate/datamodel/conf/DataSourceConfig.class]    - mysql: defined by method 'datasourceMySource' in class path resource [com/lk/rulegenerate/datamodel/conf/DataSourceConfig.class]Action:Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed 

2.配置文件配置文件.png

3.连接池配置

数据源配置.png


4.包结构包结构.png



5.pom

pom.png

闲大赋 2019年03月06日

因为你用了双数据源,所以springboot里有俩个SQLManager,spring上下问名字是以数据源前缀开始

看错误提示,BeetlSqlConfig 这个类早不存在了,你应该换用新的版本的beetl-frame-starter

  • ko889910 :可以了!(2019年03月06日)