国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

java - SSH框架中寫(xiě)分頁(yè)時(shí)service層中不能注入分頁(yè)類(lèi)
阿神
阿神 2017-06-12 09:24:51
0
3
987

service層

@Service
public class AuthorAdminServiceImpl implements IAuthorAdminService {
    @Resource
    private IAuthorAdminDao iauthoradmindao;
    @Resource
    PageUntil<AuthorAdmin> pageUntil;
@Override
    public PageUntil<AuthorAdmin> findByPage(int currentPage) {
        pageUntil.setCurrentPage(currentPage);// 當(dāng)前多少頁(yè)
        int pageSize = 3;
        pageUntil.setPagesize(pageSize);// 最多顯示多少記錄
        int totalCount = iauthoradmindao.findCount();// 數(shù)據(jù)庫(kù)中所有的記錄
        pageUntil.setTotalCount(totalCount);
        double tc = totalCount;
        Double num = Math.ceil(tc / pageSize);// 頁(yè)面顯示的總頁(yè)數(shù)=數(shù)據(jù)庫(kù)的總記錄數(shù)/最多顯示多少記錄
        pageUntil.setTotalPage(num.intValue());
        int begin = (currentPage - 1) * pageSize;// 當(dāng)前頁(yè)開(kāi)頭位置的索引
        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";
    }

#
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)}


如果不是使用注入而使用new的方法就行,請(qǐng)問(wèn)為什麼?

阿神
阿神

閉關(guān)修行中......

全部回覆(3)
世界只因有你

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

黃舟

你沒(méi)有正確使用@Resource,導(dǎo)致設(shè)定檔裡面找不到名稱(chēng)屬性為"iauthoradmindao"的,故而注入失敗!你可以將@Resource 更換成 @AutoWired 試試看。這兩個(gè)註解的注入方式是不一樣的,當(dāng)然前提是你的xml檔案中要配有"IAuthorAdminDao "類(lèi)型的

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

phpcn_u1582

我覺(jué)得 new出來(lái)最簡(jiǎn)單了。你這個(gè)類(lèi)別需要考慮到特殊的問(wèn)題嗎?

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板