今天在学MyBatis的时候需要打印student对象,如下
public class Test {
public static void main(String[] args) throws IOException{
Reader reader = Resources.getResourceAsReader("conf.xml");
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
SqlSession session = sessionFactory.openSession();
String statement = "entity.studentMapper.queryStudentByStuno";
Student student = session.selectOne(statement,1);
System.out.println(student);
session.close(); }
}
重写的toString方法为
public String toString() {
return this.stuNo +","+this.stuName +","+this.stuAge+","+this.graName;
}
输出结果为
entity.Student@35aea049
这应该是未重写的toString放法吧,可是我已经重写了toString而且显示了overrides,为什么不调用我重写的toString呢?