首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Spring Boot项目出现依赖注入异常应该怎么解决?

Spring Boot项目出现依赖注入异常应该怎么解决?

提问于 2024-03-11 11:15:01
回答 0关注 0查看 61

Description:

Field am in wow.service.AdminServiceImpl required a bean of type 'wow.mapper.AdminMapper' 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 'wow.mapper.AdminMapper' in your configuration.

Process finished with exit code 1

代码:

代码语言:text
复制
@Mapper
public interface AdminMapper {

    @Select("select user_count from t_usercount")
    Integer getUserCount();
    
}

代码语言:text
复制
@Service
@Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.DEFAULT)
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper am;

    @Override
    @Transactional(readOnly=true)
    public BackJSON getUserCount() {
        BackJSON json = new BackJSON(200);
        String count = "{\"count\":"+am.getUserCount()+"}";
        json.setData(JSONObject.parse(count));
        return json;
    }

}

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档