[英]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.