有点啰嗦,见谅
我的serviceImp是指定了名称的
@Service("categoryService")
public class CategoryServiceImp implements ICategoryService {之前在业务controller里面使用@Autowired,这样无疑是没什么问题的,名称也和@service注解里面指定的一样
@Autowired private ICategoryService categoryService;
但我后面写了一个basecontroller和baseservice类,接口和controller都继承base类,并写了一些通用方法
//baseservice接口
public interface IBaseService<Pojo extends BasePojo> {
itn add(Pojo);
}
//category接口
public interface ICategoryService extends IBaseService<Category> {
}
//basecontroller
public class BaseController<Pojo extends BasePojo, Service extends IBaseService<Pojo>> {
@Autowired
private Service service;
@requestMapping("/add")
public string add(Pojo pojo) {
service.add(pojo);
}
}
//业务controller
@Controller
public class CategoryController extends BaseController<Category, ICategoryService> {
}我的问题是,我在使用业务controller的时候,调用父类的方法,能正常执行,但我只是我把ICategoryService当作泛型传进去,但这样的话并没有指定一个名称,为什么会找到“categoryService”这个bean呢?,那之前我@service("beanName") 里面设置的名称岂不是没有意义了?
慕粉4241372
qq_20151109_0
随时随地看视频慕课网APP
相关分类