这个错误是什么原因。。。

ahaqzylx3_4 2014-11-05 01:26:10
错误展示:java.lang.Exception: Method getUserList should have no parameters
test:
public class Usertest {
private static SqlSessionFactory sqlSessionFactory;
private static Reader reader;

static{
try{
reader=Resources.getResourceAsReader("Configuration.xml");
sqlSessionFactory=new SqlSessionFactoryBuilder().build(reader);
}catch(Exception e){
e.printStackTrace();
}
}
public static SqlSessionFactory getSession() {
return sqlSessionFactory;
}
@Test
public void getUserList(String userName){
SqlSession session=sqlSessionFactory.openSession();
try{
IUserOperation userOperation=session.getMapper(IUserOperation.class);
List<User> users=userOperation.selectUsers(userName);
for(User user:users){
System.out.println(user.getId()+""+user.getUserName()+""+user.getUserAddress());
}
}finally{
session.close();
}
}
}

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>
<typeAlias alias="User" type="com.yihaomen.mybatis.model.User"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.0.250:3306/Wong"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/yihaomen/mybatis/model/User.xml"/>
</mappers>
</configuration>

User.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.yihaomen.mybatis.inter.IUserOperation">
<!-- 为了返回list类型而定义的returnMap-->
<resultMap type="User" id="resultListUser">
<id column="id" property="id"/>
<result column="userName" property="userName"/>
<result column="userAge" property="userAge"/>
<result column="userAddress" property="userAddress"/>
</resultMap>
<select id="selectUserByID" parameterType="int" resultType="User">
select * from user where id = #{id}
</select>
<!-- 返回LIST的select语句。。注意resultMap的值是指向前面定义好的 -->
<select id="selectUsers" parameterType="String" resultMap="resultListUser">
select * from user where userName = #{userName}
</select>
</mapper>
...全文
188 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahaqzylx3_4 2014-11-05
  • 打赏
  • 举报
回复
好了。。。Junit里面不应该有参数。。。
ahaqzylx3_4 2014-11-05
  • 打赏
  • 举报
回复
不加参数的话。。出来没有结果的
tony4geek 2014-11-05
  • 打赏
  • 举报
回复
去掉参数看看, public void getUserList( ){

51,407

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧