跟着尚硅谷的CRUD-SSM教程,配置spring环境配置文件applicationContext.xml时,插入以下bean标签,
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--读入mybatis-config配置文件-->
<property name="configLocation" value="classpath:mybatis-config"></property>
<!--引入数据源-->
<property name="dataSource" ref="dataSource"></property>
<!--读取mapper文件(存放了sql语句)-->
<property name="mapperLocations" value="classpath:mappers/*.xml"></property>
</bean>
其中
<property name="mapperLocations" value="classpath:mappers/*.xml"></property>
会报红,只需要在resources/mappers下创建任意.xml文件即可,但这会导致标题错误的产生。
只需要进入 项目名\target\XXX-1.0-SNAPSHOT\WEB-INF\classes\mappers下删除当时创建的 .xml文件 即可