博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘da
阅读量:3947 次
发布时间:2019-05-24

本文共 1035 字,大约阅读时间需要 3 分钟。

  今天在springboot项目中集成mysql的时候,项目在启动的过程中报了如下错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource': Unsatisfied dependency expressed through field'basicProperties';  nested exception is org.springframework.beans.factory.BeanCreationException: Error  creating bean with name 'spring.datasource org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Instantiation of bean  failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed  to instantiate [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]:  Constructor threw exception; nested exception is java.lang.NoClassDefFoundError:  org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType

原因:

  如果项目中没有导入mybatis相关依赖,则springboot启动时会自动去加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,我们可以使用@configuration注解来向spring容器中注入datasource bean,但是如果项目中没有datasource bean,则会注入失败。

解决:

  检查一下项目得pom依赖中是否导入了mybatis得相关依赖,或者在项目中将datasource bean注入到spring容器中

转载地址:http://xphwi.baihongyu.com/

你可能感兴趣的文章
Sending the User to Another App
查看>>
Getting a Result from an Activity
查看>>
Allowing Other Apps to Start Your Activity
查看>>
Using the Location Manager
查看>>
Obtaining the Current Location
查看>>
Displaying the Location Address
查看>>
Connecting to the Network
查看>>
Managing Network Usage
查看>>
Parsing XML Data
查看>>
Optimizing Downloads for Efficient Network Access
查看>>
Minimizing the Effect of Regular Updates
查看>>
Redundant Downloads are Redundant
查看>>
Modifying your Download Patterns Based on the Connectivity Type
查看>>
Supporting Different Screen Sizes支持不同的屏幕尺寸
查看>>
Supporting Different Densities 支持各种屏幕密度
查看>>
Implementing Adaptative UI Flows 实施自适应用户界面流程
查看>>
Crossfading Two Views 淡入淡出的两种观点
查看>>
Using ViewPager for Screen Slides 使用屏幕幻灯片ViewPager
查看>>
Displaying Card Flip Animations 显示卡片翻转动画
查看>>
Zooming a View 缩放视图
查看>>