1、修改pom.xml,添加resources节点,将/src/main/java下的xml文件设置为资源文件
<build>
<finalName>springWebTest</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
2、将mapper.xml放到resources文件夹下面,同时修改spring-mybatis.xml文件中 mapper.xml的路径
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:mapper/*Mapper.xml"></property>
</bean>