mybatis配置通用mapper报错,请大侠们帮帮忙,谢谢 403.10 禁止访问:配置无效 -问答-阿里云开发者社区-阿里云

开发者社区> kun坤> 正文

mybatis配置通用mapper报错,请大侠们帮帮忙,谢谢 403.10 禁止访问:配置无效 

2020-05-27 14:01:40 165 1

我只这样配置的,如下:

<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-acting\eclipse4.3.1\workspace\zbx.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvcmybatis\WEB-INF\classes\com\IDao\MidUserMapper.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-acting\eclipse4.3.1\workspace\zbx.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvcmybatis\WEB-INF\classes\spring\spring-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-acting\eclipse4.3.1\workspace\zbx.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvcmybatis\WEB-INF\classes\com\IDao\MidUserMapper.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-acting\eclipse4.3.1\workspace\zbx.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvcmybatis\WEB-INF\classes\spring\spring-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-acting\eclipse4.3.1\workspace\zbx.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvcmybatis\WEB-INF\classes\spring\spring-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)

取消 提交回答
全部回答(1)
  • kun坤
    2020-05-27 14:53:59

    推荐使用  Mybatis-Plus 启动加载 XML 配置时注入单表 SQL 操作 ,启动注入非拦截实现、使用简单,性能更优。 ######你好,mybatis-plus是个工具的集合包吧?不是一个具体的工具吧?######谢谢######看起来是配置有问题,你时参照官方示例来做的吗######回复 @marshalbin : 参照官方样列,很容易的啊,给出你的代码######是的,就是配置完了有问题,请问您有这方面的经验吗?能否指导一下?###### 关于mybatis和spring的详细配置,可关注:http://git.oschina.net/wangkang/llsfw
    希望能够帮到你. ###### Caused by: java.lang.IllegalStateException: Cannot convert value of type [tk.mybatis.spring.mapper.MapperScannerConfigurer] to required type 
    查查这两句吧,没见过类似的错误,你用mybatis的拦截器了? ######

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

    看起来是配置有问题,你时参照官方示例来做的吗
    <!-- DAO接口所在包名,Spring会自动查找其下的类 -->  

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

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

            <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  

        </bean>  
    上面是代码,请看看有问题吗? ######这样看看不出来问题啊######

    <value> mappers=tk.mybatis.mapper.common.Mapper

       </value></pre> 修改为 
    
    <value>
            tk.mybatis.mapper.common.Mapper
            
           </value>
    0 0
相关问答

40

回答

[@徐雷frank][¥20]什么是JAVA的平台无关性

大河人家 2018-10-29 23:55:20 144248浏览量 回答数 40

162

回答

惊喜翻倍:免费ECS+免费环境配置~!(ECS免费体验6个月活动3月31日结束)

豆妹 2014-10-29 17:52:21 222948浏览量 回答数 162

8

回答

OceanBase 使用动画(持续更新)

mq4096 2019-02-20 17:16:36 333795浏览量 回答数 8

13

回答

[@饭娱咖啡][¥20]我想知道 Java 关于引用那一块的知识

心意乱 2018-10-31 18:44:12 142126浏览量 回答数 13

110

回答

OSS存储服务-客户端工具

newegg11 2012-05-17 15:37:18 292236浏览量 回答数 110

22

回答

爬虫数据管理【问答合集】

我是管理员 2018-08-10 16:37:41 146750浏览量 回答数 22

18

回答

阿里云开放端口权限

xcxx 2016-07-20 15:03:33 643031浏览量 回答数 18

31

回答

[@倚贤][¥20]刚学完html/css/js的新手学习servlet、jsp需要注意哪些问题?

弗洛伊德6 2018-10-27 21:52:43 145588浏览量 回答数 31

42

回答

【精品问答集锦】Python热门问题

小六码奴 2019-05-30 15:27:34 135468浏览量 回答数 42

10

回答

[@墨玖tao][¥20]为什么流式处理框架都是 java 写成的,JVM 是不是在流和批存在着特殊优势。还有分布式资源调度,感觉Mesos 的成长速度跟不上 Yarn。这是为什么?

管理贝贝 2018-10-23 13:18:03 136114浏览量 回答数 10
+关注
0
文章
13401
问答
推荐问答
相关电子书
更多
文娱运维技术
立即下载
《SaaS模式云原生数据仓库应用场景实践》
立即下载
《看见新力量:二》电子书
立即下载