我解决了。有两件事要考虑。
首先,我用eclipse生成了mvc portlet,它将旧版本的内核依赖项放在build.gradle文件中。我把它们改成:
compileOnly group: 'com.liferay.portal', name: 'com.liferay.portal.kernel', version: '3.0.1'
compileOnly group: 'com.liferay.portal', name: 'com.liferay.util.taglib', version: '3.0.0'
第二,在portlet的
@Component
中的批注
property { ... }
我添加的列表:
"com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet",
"com.liferay.portlet.application-type=widget",
"com.liferay.portlet.application-type=full-page-application",
"javax.portlet.name=my-custom-portlet",
除了已经存在的东西。
所以在我看来
@组件
看起来像
@Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=my-custom-portlet Portlet",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user",
"javax.portlet.name=my-custom-portlet",
"com.liferay.fragment.entry.processor.portlet.alias=my-custom-portlet",
"com.liferay.portlet.application-type=widget",
"com.liferay.portlet.application-type=full-page-application",
"com.liferay.portlet.add-default-resource=true"
},
service = Portlet.class
)
public class MyCustomPortlet extends MVCPortlet {
以及
build.gradle
文件看起来像
dependencies {
compileOnly group: 'com.liferay.portal', name: 'com.liferay.portal.kernel', version: '3.0.1'
compileOnly group: 'com.liferay.portal', name: 'com.liferay.util.taglib', version: '3.0.0'
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
compileOnly group: "jstl", name: "jstl", version: "1.2"
compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
}