将google-cloud-datastore依赖项添加到模块化Java 11项目时,java.lang.module.ResolutionException [英] java.lang.module.ResolutionException when adding google-cloud-datastore dependency to modular Java 11 project

查看:108
本文介绍了将google-cloud-datastore依赖项添加到模块化Java 11项目时,java.lang.module.ResolutionException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JDK 11上运行了基于模块化泽西的微服务.它可以很好地部署到Google App Engine.可以在此处下载代码(或克隆主项目并切换到3.1标记): https://github.com/Leejjon/SimpleJerseyService/releases/tag/3.1

I have a modular jersey based microservice running on JDK 11. It deploys fine to Google App Engine. The code can be downloaded here (or clone the main project and switch to the 3.1 tag): https://github.com/Leejjon/SimpleJerseyService/releases/tag/3.1

现在,我想添加对Google Cloud Datastore API(在我以前的非模块化Java 8项目中可用)的访问权限.因此,我添加了Maven依赖项:

Now I want to add access to the Google Cloud Datastore API (which worked on my previous non modular Java 8 project). So I add the maven dependency:

<dependency>
   <groupId>com.google.cloud</groupId>
   <artifactId>google-cloud-datastore</artifactId>
   <version>1.80.0</version>
</dependency>

然后我将 requires google.cloud.datastore; 添加到我的module-info.java.

And I add requires google.cloud.datastore; to my module-info.java.

一个 mvn全新安装运行正常,但是当我通过 mvn exec:exec java -p simple-service-1.0-SNAPSHOT.jar运行它时;appengine-staging/-m myModule/com.example.Main localhost

A mvn clean install runs fine but when I run it via mvn exec:exec or java -p simple-service-1.0-SNAPSHOT.jar;appengine-staging/ -m myModule/com.example.Main localhost

我得到:

Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules grpc.context and grpc.api export package io.grpc to module org.apache.httpcomponents.httpclient

在我的module-info.java中可以做些什么来解决此问题?

Is there anything I can do in my module-info.java to fix this problem?

阅读以下帖子后: https://blog.codefx.org/java/java-9-migration-guide/#Split-Packages https://blog.codefx.org/java/jsr-305-java-9/#Modular-Project 模块A和B将包some.package导出到Java 9中的模块C

我怀疑这个google-cloud-datastore库尚未准备好用于Java模块系统.我将参考此stackoverflow帖子在Google Cloud Client API github上发布问题.

I'm suspecting this google-cloud-datastore library just isn't ready for the Java Module System. I will post an issue on the Google Cloud Client API github refering to this stackoverflow post.

推荐答案

pmakani from github managed to "fix" my project by excluding dependencies:

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.80.0</version>
<exclusions>
   <exclusion>
       <groupId>com.google.code.findbugs</groupId>
       <artifactId>jsr305</artifactId>
   </exclusion>
   <exclusion>
       <groupId>io.grpc</groupId>
       <artifactId>grpc-core</artifactId>
   </exclusion>
</exclusions>
</dependency>

似乎可以访问数据存储,但是日志中仍然包含类似以下错误:java.lang.reflect.InaccessibleObjectException:无法使字段保护的易失性java.io.InputStream java.io.FilterInputStream.in可访问:模块java.base不会打开java.io"模块数据

Accessing the datastore seems to work, however the log still contains errors like: java.lang.reflect.InaccessibleObjectException: Unable to make field protected volatile java.io.InputStream java.io.FilterInputStream.in accessible: module java.base does not "opens java.io" to module data

完整日志: https://pastebin.com/e431R7pW

我想Google仍应将其gcloud库(及其依赖的所有依赖项)模块化.

I suppose Google should still make their gcloud libs (and all the dependencies they depend on) modular.

这篇关于将google-cloud-datastore依赖项添加到模块化Java 11项目时,java.lang.module.ResolutionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆