关于SSM错误:'org.mybatis.spring.SqlSessionFactoryBean#0'

SSM代码报错:

Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.SqlSessionFactoryBean#0' defined in class path resource [appInfoContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
 

Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; 
nested exception is org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'org.mybatis.spring.SqlSessionFactoryBean#0' defined in class path resource [appInfoContext.xml]:
 Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException;
 nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy

开始以为是dateSource配错了,看了半天,后来看到tomcat的log信息

Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy

没有发现我这个类,我也不知道这是什么类,看到springframeworkjdbc,乍一看,是spring -jdbc没有配.奇怪了,以前也没配过,第一次遇到这个错.

 <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
 </dependency>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 这个异常通常发生在Spring应用程序中,当Spring容器无法满足某个bean的依赖关系时。具体而言,它意味着某个bean所依赖的其他bean无法被正确注入。根据提供的引用内容,可能有几个原因导致这个异常的出现。 首先,错误消息中提到的bean可能没有在Spring的上下文中正确配置。在这种情况下,您需要确保该bean的定义正确,包括正确的包路径、正确的类名和正确的依赖项。 其次,这个异常还可能是由于jar包冲突引起的。在引用中提到的mybatis-3.2.8.jar可能与其他版本的mybatis冲突。您可以尝试排除冲突的jar包或修复pom.xml文件中的依赖项来解决这个问题。 此外,异常信息中还提到了注解的使用。在引用中提到了@Service、@Autowired等注解的使用。确保这些注解被正确地应用在所需的类和字段上,并且它们的引用是唯一且正确的。 最后,也可能是启动类的配置问题。请确保在启动类中正确配置了@ComponentScan和@MapperScan注解,以确保所有的mapper被正确扫描并注入。 综上所述,要解决这个异常,您需要检查bean的配置、解决jar包冲突、确保注解正确应用和配置正确的启动类。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [spring-beans-5.2.0.RELEASE-API文档-中英对照版.zip](https://download.csdn.net/download/qq_36462452/86086690)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [org.springframework.beans.factory.UnsatisfiedDependencyException异常问题的解决](https://blog.csdn.net/shenxiaomo1688/article/details/102635984)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name](https://blog.csdn.net/qq_44973310/article/details/128302144)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值