BeanInstantiationException Could not instantiate bean class [User]Is it an abstract class?;
錯誤資訊如下
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cn.com.day03.User]: Is it an abstract class?; nested exception is java.lang.InstantiationException: cn.com.day03.User
at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:81)
at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:236)
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:706)
Caused by: java.lang.InstantiationException: cn.com.day03.User
at java.lang.Class.newInstance0(Class.java:357)
原因:
User類裡面沒有無參的構造器
在Spring操作的整個流程中,要注意的是類(有屬性的)裡面一定要有無參的構造方法;