Description:
Field commentMapper in com.xxx.xxx.service.CommentService required a bean of type ‘com.xxx.xxx.dao.CommentMapper’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘com.xxx.xxx.dao.CommentMapper’ in your configuration.
Disconnected from the target VM, address: ‘127.0.0.1:55098’, transport: ‘socket’
Process finished with exit code 0
在dao层加@Mapper注解
@Mapper
public interface CommentMapper {
// 查看帖子回复列表
List<Comment> selectCommentsByEntity(int entityType, int entityId, int offset, int limit);
// 查看帖子回复数量
int selectCommentCountByEntity(int entityType, int entityId);
}
本文探讨了在Spring Boot应用中,CommentService因找不到CommentMapper类型bean而报错的解决方案。通过在配置文件中定义CommentMapper bean并添加@Autowired注解,解决了自动装配问题。遇到此类问题时,检查bean定义和依赖路径至关重要。
2882

被折叠的 条评论
为什么被折叠?



