av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:98日期: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);// 當(dāng)前多少頁int pageSize = 3;pageUntil.setPagesize(pageSize);// 最多顯示多少記錄int totalCount = iauthoradmindao.findCount();// 數(shù)據(jù)庫中所有的記錄pageUntil.setTotalCount(totalCount);double tc = totalCount;Double num = Math.ceil(tc / pageSize);// 頁面顯示的總頁數(shù)=數(shù)據(jù)庫的總記錄數(shù)/最多顯示多少記錄pageUntil.setTotalPage(num.intValue());int begin = (currentPage - 1) * pageSize;// 當(dāng)前頁開頭位置的索引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框架中寫分頁時(shí)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框架中寫分頁時(shí)service層中不能注入分頁類java - SSH框架中寫分頁時(shí)service層中不能注入分頁類

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

問題解答

回答1:

PageUntil這個(gè)類也是要用@Component

回答2:

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

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

回答3:

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

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 国际精品鲁一鲁一区二区小说 | 精品一区二区久久久久久久网站 | 深夜爽视频 | 精品国产一区二区三区av片 | 久久久久久久久久性 | 国产av毛片 | 中文在线一区 | 久久91| 免费成人午夜 | 亚洲成人综合在线 | 一区二区三区av | 国产成人短视频在线观看 | 青青草华人在线视频 | 国产成人精品久久二区二区91 | 久久久久久久久久久久久久国产 | 亚洲精品久久久久久首妖 | 中国xxxx性xxxx产国 | 日本国产欧美 | 祝你幸福电影在线观看 | 91久久久久久久久久久久久 | 视频一区在线 | 久草在线视频中文 | 亚洲欧洲av在线 | 国产高清一区二区三区 | 99久久免费精品国产免费高清 | 成人h动漫亚洲一区二区 | 中国一级特黄毛片大片 | 国产精品九九九 | 国产不卡视频 | 极品久久| 91不卡在线 | 天堂av中文在线 | 91精品国产色综合久久不卡98 | 欧美一区二区三区在线观看 | 日韩在线高清 | 欧美一页| 精品粉嫩aⅴ一区二区三区四区 | 亚洲综合婷婷 | 国产精品久久久久久久久久三级 | 日韩精品在线一区二区 | 激情久久网 |