spring3將普通的java類納入到spring的容器中進行管理
阿新 • • 發佈:2019-02-01
@Configuration public class CategoryUtil { public static ICategoryService categoryService; private int pid; @Autowired public void setCategoryService(ICategoryService categoryService) { System.out.println("初始化categoryService"); this.categoryService = categoryService; } public CategoryUtil() { } public static List<Category> getList(int pid) { List<Category> cateList=null; cateList= categoryService.getCategoryList(pid); return cateList; } public int getPid() { return pid; } public void setPid(int pid) { this.pid = pid; } }
spring3的好處可以支援讓普通的bean受管與spring容器
很喜歡