繁体   English   中英

尝试在Portlet中获取Web内容时出现Liferay 7错误

[英]Liferay 7 Error when trying to get web content inside portlet

我正在尝试使用JournalArticleServiceUtil类获取Web内容,但显示错误,我不知道如何解决,这是我的代码

long groupId = themeDisplay.getLayout().getGroupId();
    System.out.println("GroupId: " + groupId);
    List<JournalArticle> articleList = new ArrayList<>();
    List<String> news = new ArrayList<>();
    try {
        DDMStructure structure = DDMStructureManagerUtil.getStructure(Long.parseLong("94203"));
        articleList = JournalArticleServiceUtil.getArticlesByStructureId(groupId, structure.getStructureKey(), 0, 10, null);
        for (JournalArticle art: articleList) {
            news.add(art.getContent());
        }

    } catch (SystemException e) {
        log.error(e.getMessage());
    } catch (NumberFormatException e) {
         log.error(e.getMessage());
    } catch (PortalException e) {
        log.error(e.getMessage());
    }

错误说

com.sun.proxy.$Proxy466 cannot be cast to com.liferay.journal.service.JournalArticleService

我希望你能帮助我

这似乎与您使用的服务类的实现版本有关。 如果使用gradle,则可以优先选择compileOnly规则,并确保将服务器中的内核版本与所使用的版本匹配。 有时您确实需要直接在bnd.bnd上声明实现版本。

就像是:

Import-Package: com.liferay.journal.model;version="[1.0.0,3.0.0)", com.liferay.journal.service; version="[1.0.0,3.0.0)",*

我认为您应该尝试使用JournalArticleLocalServiceUtil而不是JournalArticleServiceUtil

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM