Could not autowire. No beans of 'xxxMapper' type found.

作爲一名剛開始使用idea的新手,最近在使用maven+springMVC框架時遇到了這樣一個問題:Could not autowire. No beans of ‘xxxMapper’ type found.
這是在實現xxxService接口時,自動注入xxxMapper時,出現的錯誤。
(╯‵□′)╯︵┴─┴

package com.zm.mlog.service.impl;

import com.zm.mlog.mapper.AdminMapper;
import com.zm.mlog.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("adminService")
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
}

看了很久的代碼,實在是沒發現問題。甚至把代碼拿到eclipes跑,沒問題。
┬─┬ ノ( ’ - 'ノ) {擺好擺好)
(再掀一次} (╯°Д°)╯︵ ┻━┻
當然此時已經意識到不是代碼的問題_(:з」∠)_
好了不皮了,解決方法如下:
這裏寫圖片描述

這裏寫圖片描述

解決方法來源於:http://blog.csdn.net/u012453843/article/details/54906905

好久沒有管理博客更新一下。。。今天剛看到 neosoul9818大佬 給了更靠譜的方法:
@Autowired改成@resource就可以了

發佈了35 篇原創文章 · 獲贊 11 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章