在mybatis和spring整合中使用spring的MapperScannerConfigurer 运行出错? 400 报错 DEBUG [main] - Initializing new StandardEnvironment
DEBUG [main] - Adding [systemProperties] PropertySource with lowest search precedence
DEBUG [main] - Adding [systemEnvironment] PropertySource with lowest search precedence
DEBUG [main] - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
DEBUG [main] - Looking for matching resources in directory tree [E:\myworkspace\mybatis_spring3\bin\com\nemo\ssm\mapper]
DEBUG [main] - Searching directory [E:\myworkspace\mybatis_spring3\bin\com\nemo\ssm\mapper] for files matching pattern [E:/myworkspace/mybatis_spring3/bin/com/nemo/ssm/mapper/**/*.class]
DEBUG [main] - Resolved location pattern [classpath*:com/nemo/ssm/mapper/**/*.class] to resources [file [E:\myworkspace\mybatis_spring3\bin\com\nemo\ssm\mapper\UserMapper.class], file [E:\myworkspace\mybatis_spring3\bin\com\nemo\ssm\mapper\UserMapperTest.class]]
INFO [main] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71318ec4: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0]; root of factory hierarchy
spring和mybatis整合,需要添加mybatis-spring,需要使用spring来启动添加的插件来初始化mybatis,然后在spring里面注入######@阿信sxq 用你的代码试了,但xml文件会提示The prefix "mybatis" for element "mybatis:scan" is not bound. 怎么解决啊?######回复 @渊兮 : ssm 架构参考 http://git.oschina.net/juapk/SpringWind######整合包我已经添了。如果使用使用MapperFactoryBean的话 不报错。用批量扫描MapperScannerConfigurer的话就会报这一错误。实在想不明白。搜了很多也没找到正确的答案。。。######
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:mybatis-config.xml" /> <property name="mapperLocations" value="classpath:mapper/*.xml" /> </bean> <!-- 自动加载dao --> <mybatis:scan base-package="com.xxxxxx.dao" />
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mybatis="http://mybatis.org/schema/mybatis-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd">
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。