这是异常
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.prs.dps.dao.IPoetDao.getPoetById
PoetMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.prs.dps.dao.IPoetDao" >
<resultMap id="userResultMap" type="poet">
<id property="id" column="user_id" />
<result property="username" column="username"/>
<result property="password" column="password"/>
<result property="fullName" column="fullName"/>
<result property="email" column="email"/>
<result property="updateByEmail" column="updateByEmail"/>
</resultMap>
<select id="getPoetById" resultMap="userResultMap">
select from poet where id = #{id}
</select>
</mapper>
IPoetDao
package com.prs.dps.dao;
import com.prs.dps.domain.Poet;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by ffulauh on 2016/6/4.
*/
@Repository("poetDao")
public interface IPoetDao {
List<Poet> getPoetById(Integer id) throws Exception;
}
mybatis配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/dps?useUnicode=true&characterEncoding=utf8" />
<property name="username" value="root" />
<property name="password" value="02041992" />
<property name="initialSize" value="0" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="20" />
<property name="minIdle" value="0"/>
<property name="maxWait" value="10000" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:com/prs/dps/mapper/*Mapper.xml" />
<property name="configLocation" value="/WEB-INF/config/mybatis/mybatis-configuration.xml"/>
</bean>
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory"></constructor-arg>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.prs.dps.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
</beans>
mybatis-configuration.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">
<configuration>
<typeAliases>
<!--portal-->
<typeAlias type="com.prs.dps.domain.Poet" alias="poet"></typeAlias>
</typeAliases>
</configuration>
不一定是你想要的,不过我觉得可以试试:
或者: