未解决的要求:导入包:com.liferay.docs.guestbook.model;版本= "[1.0.0,1.1.0)" _



这个项目的版本是7.2ga1,我使用Liferay Tomcat 7.3.5。我刚刚尝试使用目标平台,但没有结果。这里有tomcat的日志,当我部署项目时。

2020-11-23 11:03:21.019 ERROR [fileinstall-C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules][DirectoryWatcher:1112] Unable to start bundle: file:/C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules/com.liferay.docs.guestbook.service.jar
org.osgi.framework.BundleException: **Could not resolve module: com.liferay.docs.guestbook.service [2425]_  Unresolved requirement: Import-Package: com.liferay.docs.guestbook.exception; version="[1.0.0,2.0.0)"_**    -> Export-Package: com.liferay.docs.guestbook.exception; bundle-symbolic-name="com.liferay.docs.guestbook.api"; bundle-version="1.0.0"; version="1.0.0"; uses:="com.liferay.portal.kernel.exception"_       com.liferay.docs.guestbook.api [2423]_         Unresolved requirement: Import-Package: com.liferay.portal.kernel.dao.orm; version="[9.6.0,10.0.0)"_  Unresolved requirement: Import-Package: com.liferay.docs.guestbook.model; version="[1.0.0,1.1.0)"_    -> Export-Package: com.liferay.docs.guestbook.model; bundle-symbolic-name="com.liferay.docs.guestbook.api"; bundle-version="1.0.0"; version="1.0.0"; uses:="com.liferay.exportimport.kernel.lar,com.liferay.portal.kernel.annotation,com.liferay.portal.kernel.bean,com.liferay.portal.kernel.model,com.liferay.portal.kernel.model.wrapper,com.liferay.portal.kernel.util"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1095)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1128)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startAllBundles(DirectoryWatcher.java:1073)
at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:985)
2020-11-23 11:03:21.022 ERROR [fileinstall-C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules][DirectoryWatcher:1112] Unable to start bundle: file:/C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules/com.liferay.docs.guestbook.api.jar
org.osgi.framework.BundleException: Could not resolve module: com.liferay.docs.guestbook.api [2423]_  Unresolved requirement: Import-Package: com.liferay.portal.kernel.dao.orm; version="[9.6.0,10.0.0)"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1095)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1128)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startAllBundles(DirectoryWatcher.java:1073)
at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:985)
at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:302)
2020-11-23 11:03:21.025 ERROR [fileinstall-C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules][DirectoryWatcher:1112] Unable to start bundle: file:/C:/java/bundles/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029/liferay-ce-portal-7.3.4-ga5/osgi/modules/com.liferay.docs.guestbook.api.jar
org.osgi.framework.BundleException: Could not resolve module: com.liferay.docs.guestbook.api [2423]_  Unresolved requirement: Import-Package: com.liferay.portal.kernel.dao.orm; version="[9.6.0,10.0.0)"_ [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1095)
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1128)
at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:990)
at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:302)

这是我执行Gradle任务buildService 时自动生成的代码

服务代码build.gradle

dependencies {
compileOnly project(":modules:guestbook:guestbook-api")

compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"
}

buildService {
apiDir = "../guestbook-api/src/main/java"
}

group = "com.liferay.docs.guestbook"

tasks.withType(JavaCompile) {

// Generated classes using Jodd library are unable to be read when compiled against JDK 11

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

这是我执行Gradle任务buildService 时自动生成的代码

api build.gradle 代码

dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"

服务代码bnd.bnd

Bundle-Name: guestbook-service
Bundle-SymbolicName: com.liferay.docs.guestbook.service
Bundle-Version: 1.0.0
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
-dsannotations-options: inherit`

这是我执行Gradle任务buildService 时自动生成的代码

**CODE OF Api bdn.bdn** 

Bundle-Name: guestbook-api
Bundle-SymbolicName: com.liferay.docs.guestbook.api
Bundle-Version: 1.0.0
Export-Package:
com.liferay.docs.guestbook.exception,
com.liferay.docs.guestbook.model,
com.liferay.docs.guestbook.service,
com.liferay.docs.guestbook.service.persistence
-check: EXPORTS
-includeresource: META-INF/service.xml=../guestbook-service/service.xml


所以我不明白为什么服务不能导入API的包。

但是,请参阅下面的链接。

这是Liferay让你做的项目,如果你是一个原则,我遵循这个

您从开始

这个项目的版本是7.2ga1,我使用Liferay Tomcat 7.3.5

并且您声明您已经尝试过目标平台。事实上,构建依赖关系表明您仍在使用目标平台,并且很可能您的目标平台被设置为与您正在使用的运行时不同的版本:目标平台至少应该匹配主要/次要部分(例如7.3.x(,对其深度有不同的意见。最简单的方法是:使您的目标系统与您在运行时使用的版本匹配。

您的服务无法导入API捆绑包,因为API捆绑包未部署:由于编译时(通过目标平台(引入的版本不匹配,它依赖运行时不存在的Liferay内核。

将目标平台设置为7.3.5,进行干净的重建,并且您的依赖项应该与您的运行时版本匹配

回答您的评论:这样,您就可以在插件中声明正确的依赖项,并在运行时进行匹配。您的build.gradle不包含任何版本号,因为这些版本来自目标平台声明。如果你在bnd.bnd中重写任何依赖项的版本(到0(,该版本将被忽略,但不能保证你有兼容的代码,确实可以处理他们在运行时发现的内容。只需关闭正确的依赖项现在就可以工作,但只要您所依赖的API更新为二进制不兼容的更改,就可能失败。

最新更新