简体   繁体   English

java.sql.Time 异常

[英]java.sql.Time exception

does anybody met something like that?有没有人遇到过这样的事情? After switching to JAVA 9 I faced such problem切换到 JAVA 9 后,我遇到了这样的问题

Caused by: java.lang.NoClassDefFoundError: java/sql/Time
    at com.google.gson.Gson.<init>(Gson.java:240)
    at com.google.gson.GsonBuilder.create(GsonBuilder.java:569)
    at net.thucydides.core.reports.json.gson.GsonJSONConverter.<init>(GsonJSONConverter.java:50)
    at net.thucydides.core.reports.json.gson.GsonJSONConverter$$FastClassByGuice$$6794eb79.newInstance(<generated>)
    at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:194)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1085)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1015)
    ... 25 more
Caused by: java.lang.ClassNotFoundException: java.sql.Time
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    ... 42 more

I tried different java version, also gson library was not updated, I mean the same package was working on java 8. Any suggestion?我尝试了不同的 java 版本,gson 库也没有更新,我的意思是同一个包在 java 8 上工作。有什么建议吗?

Add java.sql to your module-info.java file: 将java.sql添加到您的module-info.java文件中:

module MODULE_NAME {
    ...
    requires java.sql;
    ...
}

java.sql is a module, java9 sql module java.sql是一个模块, java9 sql模块

Try: 尝试:

java --module-path lib --add-modules java.sql

for my case it start works after i run it with JAR manifest configured 在我的情况下,在配置了JAR清单的情况下运行它之后,它开始工作

在此处输入图片说明

The following helped me. 以下帮助了我。 IDE: Run-> Edit Configurations and in the "Shorten command line" field select the "JAR manifest" IDE:运行->编辑配置,然后在“ Shorten命令行”字段中选择“ JAR清单”

Gson has default adapters for some SQL types (one of that is java.sql.Time ). Gson 有一些 SQL 类型的默认适配器(其中之一是java.sql.Time )。 Since Java 9 the SQL classes are in their own module ( java.sql ).从 Java 9 开始,SQL 类位于它们自己的模块 ( java.sql ) 中。 Most likely that module was not included by default for you when you executed your program.当您执行程序时,很可能默认情况下未包含该模块。

However, starting with Gson 2.8.9 the dependency on the SQL types is optional.但是,从Gson 2.8.9开始,对 SQL 类型的依赖是可选的。 You can use Gson without any issues, even if they are not present.您可以毫无问题地使用 Gson,即使它们不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM