亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

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

瀏覽:78日期: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框架中寫分頁時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,導(dǎo)致配置文件里面找不到名稱屬性為'iauthoradmindao'的<bean>,故而注入失敗!你可以將@Resource 更換成 @AutoWired 試試看。這兩個注解的注入方式是不一樣的,當(dāng)然前提是你的xml文件中要配有'IAuthorAdminDao '類型的<bean>

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

回答3:

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

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 涩涩色中文综合亚洲 | 国产短视频在线 | 欧美成人禁片在线观看网址 | 国产精品视频在 | 好大水好多好爽好硬好深视频 | 欧美国产综合日韩一区二区 | 一级毛片看真人在线视频 | 美女扣下面流白浆丝袜 | 欧美日韩亚洲区久久综合 | 日韩精品中文乱码在线观看 | 亚州第一视频 | 91精品成人免费国产片 | 欧美亚洲一二三区 | 亚洲 国产 路线1路线2路线 | 久久精品视频在线播放 | 日韩精品一区二区三区四区 | 欧美特黄特刺激a一级淫片 欧美特黄高清免费观看的 欧美爱片 | 久久国产美女免费观看精品 | 四虎884aa永久播放地址http | 免费国产好深啊好涨好硬视频 | 国产免费一级视频 | 欧美在线观看一区 | 免费一级毛片在线视频观看 | 性欧美成人免费观看视 | 国产乱理 | 亚洲国产成人最新精品资源 | 黄色成人在线 | 国产视频资源在线观看 | 国产成人午夜极速观看 | 亚洲黄网在线观看 | 日韩一级精品视频在线观看 | 欧美黄色软件 | 综合激情婷婷 | 日本a在线免费观看 | 欧美在线观看成人高清视频 | 国产成人精品一区二区视频 | 啪啪网站在线观看 | 高清一区二区亚洲欧美日韩 | 免费特黄一级欧美大片 | 狠狠色婷婷 | 国产永久福利 |