色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

java - SSH框架中寫分頁時service層中不能注入分頁類

瀏覽:82日期:2023-11-08 08:00:02

問題描述

service層

@Servicepublic class AuthorAdminServiceImpl implements IAuthorAdminService { @Resource private IAuthorAdminDao iauthoradmindao; @Resource PageUntil<AuthorAdmin> pageUntil;@Override public PageUntil<AuthorAdmin> findByPage(int currentPage) {pageUntil.setCurrentPage(currentPage);// 當前多少頁int pageSize = 3;pageUntil.setPagesize(pageSize);// 最多顯示多少記錄int totalCount = iauthoradmindao.findCount();// 數據庫中所有的記錄pageUntil.setTotalCount(totalCount);double tc = totalCount;Double num = Math.ceil(tc / pageSize);// 頁面顯示的總頁數=數據庫的總記錄數/最多顯示多少記錄pageUntil.setTotalPage(num.intValue());int begin = (currentPage - 1) * pageSize;// 當前頁開頭位置的索引List<AuthorAdmin> list = iauthoradmindao.findByPage(begin, pageSize);if(list==null){ System.out.println('list findByPage service error');}pageUntil.setList(list);return pageUntil; }

action層

public String listAuthorAdmin() {PageUntil<AuthorAdmin> pageuntil = iauthoradminservice.findByPage(currentPage);ActionContext.getContext().getValueStack().push(pageuntil);return 'listSuccess'; }

java - SSH框架中寫分頁時service層中不能注入分頁類

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminAction’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ’authorAdminServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.lcy.until.PageUntil com.lcy.service.author.admin.AuthorAdminServiceImpl.pageUntil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}----------Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.lcy.until.PageUntil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

java - SSH框架中寫分頁時service層中不能注入分頁類java - SSH框架中寫分頁時service層中不能注入分頁類

如果不是使用注入而使用new的方法就行,請問為什么?

問題解答

回答1:

PageUntil這個類也是要用@Component

回答2:

你沒有正確使用@Resource,導致配置文件里面找不到名稱屬性為'iauthoradmindao'的<bean>,故而注入失敗!你可以將@Resource 更換成 @AutoWired 試試看。這兩個注解的注入方式是不一樣的,當然前提是你的xml文件中要配有'IAuthorAdminDao '類型的<bean>

詳情參考:https://www.zhihu.com/questio...

回答3:

我覺得 new出來最簡單了。你這個類需要考慮到特殊的問題嗎?

標簽: java
相關文章:
主站蜘蛛池模板: 国产亚洲精品久久久久久久久激情 | 网红主播大尺度精品福利视频 | 国产精品高清全国免费观看 | 亚洲精品一区二区在线播放 | 夜夜爽影院 | 人与禽的免费一级毛片 | 国产特级全黄一级毛片不卡 | 免费看a级毛片 | 久久久这里只有精品免费 | 成人免费网站在线观看 | 99精品在线看| 欧美透逼视频 | 三级黄色高清视频 | 香港一级纯黄大片 | 久久国产影院 | 成年片免费网址网站 | 欧美日中文字幕 | 亚洲欧美精品中文字幕 | 久久成年片色大黄全免费网站 | 国产精品久久久久一区二区三区 | 中文字幕在线视频在线看 | 国产区亚洲区 | 欧美精品不卡 | 最新日韩欧美不卡一二三区 | 国产特黄特色一级特色大片 | 欧美真人视频一级毛片 | 国产亚洲综合精品一区二区三区 | 成人免费网站 | 成人在线免费视频播放 | 免费的a级毛片 | 精品国产成人高清在线 | 男人的天堂中文字幕 | 精品久久久久久综合日本 | 国产精品人伦久久 | 国产精品成人免费 | 天天躁天天碰天天看 | 91视频国产精品 | 国产一区二区三区欧美 | 亚洲免费网站观看视频 | 9191精品国产免费不久久 | 国产一区二区在线不卡 |