首页 > 数据库 >Failed to bind properties under 'spring.datasource.primary' to javax.sql.DataSource:报错

Failed to bind properties under 'spring.datasource.primary' to javax.sql.DataSource:报错

时间:2023-06-10 13:01:48浏览次数:65  
标签:11 10 06 bind 2023 --- 报错 spring main


 

2023-06-10 11:04:13.778  WARN 22452 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empController': Unsatisfied dependency expressed through field 'empService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'empMapper' defined in file [F:\FTmpCode2306\0605\hhh\target\classes\com\qqq\wwww\mappers\mapper1\EmpMapper.class]: Cannot resolve reference to bean 'primarySqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'primarySqlSessionTemplate' defined in class path resource [com/qqq/wwww/config/PrimaryDataSourceConfig.class]: Unsatisfied dependency expressed through method 'primarySqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'primarySqlSessionFactory' defined in class path resource [com/qqq/wwww/config/PrimaryDataSourceConfig.class]: Unsatisfied dependency expressed through method 'primarySqlSessionFactory' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'primaryDataSource': Could not bind properties to 'DataSource' : prefix=spring.datasource.primary, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.primary' to javax.sql.DataSource
2023-06-10 11:04:13.781  INFO 22452 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-06-10 11:04:13.792  INFO 22452 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-06-10 11:04:13.797 ERROR 22452 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'spring.datasource.primary' to javax.sql.DataSource:

    Property: spring.datasource.primary.driver-class-name
    Value: com.mysql.cj.jdbc.Driver
    Origin: class path resource [application.yml]:9:26
    Reason: Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader

Action:

Update your application's configuration

Failed to bind properties under

Failed to bind properties under

 

Failed to bind properties under 'spring.datasource.primary' to javax.sql.DataSource:报错

检查版本

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.4</version>
            <scope>runtime</scope>
        </dependency>

Failed to bind properties under

Failed to bind properties under

去掉

<version>5.1.4</version>

换成

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

Failed to bind properties under

Failed to bind properties under

 

问题解决,原因是版本冲突导致的

成功启动

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.4.RELEASE)

2023-06-10 11:07:08.066  INFO 6192 --- [           main] com.qqq.wwww.WwwwApplication             : Starting WwwwApplication on ThinkPad-Wei with PID 6192 (F:\FTmpCode2306\0605\hhh\target\classes started by 32656 in F:\FTmpCode2306\0605\hhh)
2023-06-10 11:07:08.071  INFO 6192 --- [           main] com.qqq.wwww.WwwwApplication             : No active profile set, falling back to default profiles: default
2023-06-10 11:07:09.614  WARN 6192 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.**.**.mapper]' package. Please check your configuration.
2023-06-10 11:07:10.080  INFO 6192 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 2222 (http)
2023-06-10 11:07:10.091  INFO 6192 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-06-10 11:07:10.092  INFO 6192 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
2023-06-10 11:07:10.228  INFO 6192 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-06-10 11:07:10.228  INFO 6192 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2066 ms
2023-06-10 11:07:11.027  INFO 6192 --- [           main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2023-06-10 11:07:11.123  INFO 6192 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2023-06-10 11:07:11.398  INFO 6192 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 2222 (http) with context path ''
2023-06-10 11:07:11.400  INFO 6192 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2023-06-10 11:07:11.421  INFO 6192 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2023-06-10 11:07:11.458  INFO 6192 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2023-06-10 11:07:11.680  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: addUsingPOST_1
2023-06-10 11:07:11.681  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: editUsingPUT_1
2023-06-10 11:07:11.684  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: exportUsingPOST_1
2023-06-10 11:07:11.686  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getInfoUsingGET_1
2023-06-10 11:07:11.689  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: listUsingGET_1
2023-06-10 11:07:11.691  INFO 6192 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: removeUsingDELETE_1
2023-06-10 11:07:11.711  INFO 6192 --- [           main] com.qqq.wwww.WwwwApplication             : Started WwwwApplication in 4.341 seconds (JVM running for 5.868)

Failed to bind properties under

Failed to bind properties under

Failed to bind properties under


标签:11,10,06,bind,2023,---,报错,spring,main
From: https://blog.51cto.com/u_15864767/6454444

相关文章