配置spring-mybatis.xml时,在扫描xml时一致提示报错:
网上找了好多,都不行,求大神帮忙,万分感谢!
建议你将mapper文件放在resources目录下。新建一个文件夹存放mapper文件,然后在spring-mybatis.xml中这样做:
<!-- 自动扫描mapping.xml文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:mapper/*.xml" />
</bean>
value= "classpath*:mapper/*.xml"试试有木有用呢
建议用spring-mybatis.xml 使用mybatis.xml 分离的方式,比较明了。就算整合在spring-mybatis.xml中也还是需要mybatis.xml:
配置 spring-mybatis.xml 引用mybatis 的配置文件
在 mybatis.xml 中配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- 方式一:mapper需要的xml放在dao目录下,会自动识别同名xml文件 -->
<!-- 方式二:class 级别的指定,会自动识别类同目录下同名xml文件 -->
<!-- 方式三:指定Mapper的位置 无需classpath-->
如果非要在spring-mybatis.xml 里配置 注意路径斜杆开头(classpath:/):
如果非要在spring-mybatis.xml 里配置 注意路径斜杆开头(classpath:/):
试试:
<property name="mapperLocations" value="classpath:/mapper/**/*.xml"/>
xml表头信息正确了吗
IDEA 的问题,重置facets的spring
先删除,然后在重新加载,点加号,选择spring,全选右侧xml
史上最简单的spring+springMVC+mybaits整合SSM框架~Simple-SSM
感谢各位帮助,问题竟然是我mapper文件夹里面没有xml文件,所以一直报错!
这就尴尬了 0.0