java—未解析需求:导入包:com.liferay.docs.guestbook.model;版本=“[1.0.0,1.1.0)”_

ltskdhd1  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(364)

这个项目的版本是7.2ga1,我使用liferaytomcat7.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让你做的项目,如果你是一个原则,我遵循这个

z6psavjg

z6psavjg1#

你从
这个项目的版本是7.2ga1,我使用liferaytomcat7.3.5
你说你试过目标平台。事实上,构建依赖项表明您仍然在使用目标平台,并且很可能您的目标平台设置为与您正在使用的运行时不同的版本:目标平台至少应该匹配主要/次要部分(例如7.3.x),对于它的深度有不同的意见。最简单的方法:使目标平台与运行时使用的版本匹配。
您的服务无法导入api捆绑包,因为api捆绑包没有部署:由于编译时(通过目标平台)引入的版本不匹配,它对运行时不存在的liferay内核具有依赖关系。
将目标平台设置为7.3.5,执行干净的重建,并且依赖项应该与运行时版本匹配
回答您的意见:这样您将在插件中声明正确的依赖关系,并且它将在运行时匹配。build.gradle不包含任何版本号,因为这些版本来自目标平台声明。如果您重写bnd.bnd中任何依赖项的版本(到0),则该版本将被忽略,但不能保证您拥有确实可以处理它们在运行时发现的内容的兼容代码。仅仅关闭正确的依赖关系现在可能就可以了,但是当您所依赖的api被更新为二进制不兼容的更改时,就可能失败。

相关问题