mybatis配置通用mapper报错,请大侠们帮帮忙,谢谢

发布于 2021-12-01 09:19:32 字数 13431 浏览 708 评论 9

我只这样配置的,如下:

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  

        <property name="dataSource" ref="dataSource" />  

        <!-- 自动扫描mapping.xml文件 -->  

        <property name="mapperLocations" value="classpath:com/mapping/*.xml"></property>  

        <property name="plugins">

        <array>

        <!-- 配置数据库分页的插件PageHelper -->

        <bean class="com.github.pagehelper.PageHelper">

        <property name="properties">

        <value>dialect=mysql</value>

        </property>

        </bean>

        

        <!-- 配置通用Mapper,实现单表增删查改,当表结构变动时无需重新生成配置类和文件 -->

        <bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">

        <property name="basePackage" value="com.IDao"/>

   <property name="properties">

       <value>

        mappers=tk.mybatis.mapper.common.Mapper

        

       </value>

   </property>

</bean>

        </array>

        </property>

    </bean>  

但是如下错,请大侠帮忙指导一下:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'midUserMapper' defined in file [E:tools-actingeclipse4.3.1workspacezbx.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsspringmvcmybatisWEB-INFclassescomIDaoMidUserMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [E:tools-actingeclipse4.3.1workspacezbx.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsspringmvcmybatisWEB-INFclassesspringspring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.Object[]] to required type [org.apache.ibatis.plugin.Interceptor[]] for property 'plugins'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type [org.apache.ibatis.plugin.Interceptor] for property 'plugins[1]': no matching editors or conversion strategy found

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:311)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

at org.apache.catalina.core.StandardService.start(StandardService.java:525)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)

at org.apache.catalina.startup.Catalina.start(Catalina.java:595)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'midUserMapper' defined in file [E:tools-actingeclipse4.3.1workspacezbx.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsspringmvcmybatisWEB-INFclassescomIDaoMidUserMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [E:tools-actingeclipse4.3.1workspacezbx.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsspringmvcmybatisWEB-INFclassesspringspring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.Object[]] to required type [org.apache.ibatis.plugin.Interceptor[]] for property 'plugins'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type [org.apache.ibatis.plugin.Interceptor] for property 'plugins[1]': no matching editors or conversion strategy found

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:512)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)

at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)

... 28 more

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [E:tools-actingeclipse4.3.1workspacezbx.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsspringmvcmybatisWEB-INFclassesspringspring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.Object[]] to required type [org.apache.ibatis.plugin.Interceptor[]] for property 'plugins'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type [org.apache.ibatis.plugin.Interceptor] for property 'plugins[1]': no matching editors or conversion strategy found

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)

... 43 more

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.Object[]] to required type [org.apache.ibatis.plugin.Interceptor[]] for property 'plugins'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type [org.apache.ibatis.plugin.Interceptor] for property 'plugins[1]': no matching editors or conversion strategy found

at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:591)

at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)

at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:204)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1527)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)

... 49 more

Caused by: java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type [org.apache.ibatis.plugin.Interceptor] for property 'plugins[1]': no matching editors or conversion strategy found

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:302)

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:143)

at org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:490)

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:212)

at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

好听的两个字的网名 2021-12-01 21:54:25

引用来自“阿信sxq”的评论

看起来是配置有问题,你时参照官方示例来做的吗

复古式 2021-12-01 21:54:25

这样看看不出来问题啊

怎言笑 2021-12-01 21:54:25
<value>
        mappers=tk.mybatis.mapper.common.Mapper
        
       </value>

修改为

<value>
        tk.mybatis.mapper.common.Mapper
        
       </value>

心欲静而疯不止 2021-12-01 21:54:24

是的,就是配置完了有问题,请问您有这方面的经验吗?能否指导一下?

静谧 2021-12-01 21:54:22

回复
参照官方样列,很容易的啊,给出你的代码

梅窗月明清似水 2021-12-01 21:54:21

看起来是配置有问题,你时参照官方示例来做的吗

墨洒年华 2021-12-01 21:53:55

谢谢

月牙弯弯 2021-12-01 21:53:31

你好,mybatis-plus是个工具的集合包吧?不是一个具体的工具吧?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文