ClassNotFoundException: com.liferay.portal.kernel.model.Base



我写了一个Liferay模块:

@Component(
immediate = true,
service = ModelListener.class
)
public class TopMessageListener extends BaseModelListener<JournalArticle> {
// Do stuff
}

有了这个bnd.bnd

Bundle-SymbolicName: fr.free.nrw.impl
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Import-Package: !org.apache.avalon.framework.logger, !org.apache.log 
*

这在我的build.gradle中(除其他外(:

compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileInclude group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'

它编译正常,但部署失败:

ClassNotFoundException: com.liferay.portal.kernel.model.BaseModelListener cannot be found by fr.free.nrw.impl_1.0.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:444)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

如果我用compileInclude group: "com.liferay.portal"替换compileOnly group: "com.liferay.portal"错误,错误就会消失,但我确信这不是正确的做事方式。如何正确修复上述ClassNotFoundException

请尝试此依赖项 编译仅组:"com.liferay.portal",名称:"com.liferay.portal.kernel",版本:"2.0.0"

将 httpcomponents 行复制到两行,一行compileOnly,一行runtime

compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
runtime group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'

这为我解决了问题。

相关内容

  • 没有找到相关文章

最新更新