作爲一名剛開始使用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就可以了