无法解析类型 com.liferay.petra.sql.dsl.query.DSLQuery。它是从所需的 .class 文件中间接引用的

The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files

我正在按照 here 的初学者教程创建服务,然后从另一个模块(例如 Portlet)使用它

一切顺利,直到我尝试部署它 - 生成的 类 中出现错误:The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files

找到 build.gradle 文件并添加以下依赖项:

compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"

注意:您必须在 *-api 和 *-service build.gradle 文件中添加它

我更喜欢使用更通用的方式,只需一行即可为您组织所有 Liferay 相关的导入:

compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.5-ga6"

我的工作区工作正常,第二天当我启动我的系统时,我遇到了工作区无效的问题,不知道发生了什么。我采用了新的 liferay 工作区,然后复制粘贴了我的服务构建器,然后在部署时遇到了这个问题。 无法解析类型 com.liferay.petra.sql.dsl.query.DSLQuery。它是从所需的 .class 文件中间接引用的 我试着添加

compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"

但随后面临新问题。 我不认为这种导入会有帮助,那是其他问题 幸运的是,上周我将当前的工作区以 zip 格式作为备份,现在我又导入了该 zip 并再次尝试构建服务,现在它工作正常。 谢谢