首页 新闻 会员 周边 捐助

【mybatis-spring问题】org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

0
[已关闭问题] 关闭于 2018-08-23 11:35

代码结构:

spring.xml:

<import resource="classpath:spring/spring-jdbc.xml"/>
<context:component-scan base-package="com.my.test.spring"/>
spring-jdbc.xml:
<context:property-placeholder location="classpath:conf/jdbc.properties" file-encoding="UTF-8"/>

<bean id="dataSourceCW" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>

<property name="initialSize" value="${jdbc.initialSize}"/>
<property name="minIdle" value="${jdbc.minIdle}"/>
<property name="maxActive" value="${jdbc.maxActive}"/>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSourceCW"/>
<property name="configLocation" value="classpath:mybatis/configuration.xml"/>
</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<property name="basePackage" value="com.my.test.spring.ioc.mapper"/>
</bean>
configuration.xml只配置了驼峰映射
<configuration>
<settings>
<!-- 驼峰自动映射-->
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
测试类
public class TestMapperBean {


@Test
public void testMapper111(){
ApplicationContext context = new ClassPathXmlApplicationContext("spring/spring.xml");

TestMapper mapper = context.getBean("testMapper", TestMapper.class);
List<TestBean> beanList = mapper.getTestBeanList();//报错代码
System.out.println("test id and number is : " + JSON.toJSONString(beanList));
}
}

相关类和xml
public interface TestMapper {

List<TestBean> getTestBeanList();
}

<mapper namespace="com.my.test.spring.ioc.mapper.TestMapper">

<select id="getTestBeanList" resultType="com.my.test.spring.ioc.bean.TestBean">
select * from test
</select>

</mapper>


 
不畏将来,不念过往的主页 不畏将来,不念过往 | 初学一级 | 园豆:156
提问于:2018-08-23 10:33
< >
分享
所有回答(1)
1

加载时被过滤掉了

不畏将来,不念过往 | 园豆:156 (初学一级) | 2018-08-23 11:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册