场景:
使用通用 Mapper 中 selectByPrimaryKey 根据id查询具体的用户
问题:
问题1:idea中springboot无法自动装配Could not autowire. No beans of ‘UserMapper’ type found.
解决:在自动转配的注解后面添加(required=false)
当我们在使用@Autowired注解的时候,默认required=true,表示注入的时候bean必须存在,否则注入失败。
问题2:SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@46398ada] was not registered for synchronization because synchronization is not active
浏览器中输入:http://localhost/user/3 因为已经将端口改为了80
原因:实体类中有些属性没有用包装类
解决
建议:
实体类中属性的类型全部设置为包装类,避免不必要的麻烦