Java 9模块,NoClassDefFoundError:java.sql.Date [英] java 9 modules, NoClassDefFoundError: java.sql.Date

查看:392
本文介绍了Java 9模块,NoClassDefFoundError:java.sql.Date的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Java 9运行我们的Java 8 gradle项目,因为我们希望迁移到该项目.但是,在执行单元测试时,我得到了

I tried running our java 8 gradle project with java 9, since we are looking to migrate to it. However, when executing a unit test I get a

java.lang.ClassNotFoundException: java.sql.Date例外

com.fasterxml.jackson.databind.deser.std.DateDeserializers

在代码中看起来像这样:

Looks like this in code:

static {
    Class<?>[] numberTypes = new Class<?>[] {
        ...
        java.sql.Date.class,
        ...
    };
    ...
}

我在互联网上四处张望,显然,如果您想避免为每个模块制作一个module-info.java文件,则必须添加参数--add-modules java.sql.

I have looked around on the internet, and apparently, if you want to avoid making a module-info.java file for every module, you have to add the parameter --add-modules java.sql.

我正在使用intellij,并且已将参数添加到File>Settings>Build,Execution,Deployment>Compiler>Java Compiler中的javac参数中,并且还在以虚拟机方式运行的配置中添加了该参数,但是仍然出现异常.

I am using intellij, and have added the parameter to the javac arguments in File>Settings>Build,Execution,Deployment>Compiler>Java Compiler and also in the run config as VM option, but I still get an exception.

是否有更简单的方法来执行此操作,或者我做错了什么? 谢谢

Is there an easier way to do this, or what am I doing wrong? Thanks

IntelliJ版本:

edit: IntelliJ Version:

IntelliJ IDEA 2018.1.5 (Community Edition)
Build #IC-181.5281.24, built on June 12, 2018
JRE: 1.8.0_152-release-1136-b39 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

推荐答案

在我删除了jdk9并重新添加它之后,该问题得以解决.

The issue fixed itself after I removed the jdk9 and re-added it.

这篇关于Java 9模块,NoClassDefFoundError:java.sql.Date的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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