基于Java的H2数据库无法在CLASSPATH中找到项目 [英] Java-based H2 Database cannot locate items in CLASSPATH

查看:210
本文介绍了基于Java的H2数据库无法在CLASSPATH中找到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个scala文件,已使用以下命令编译:

I have a scala file has been compiled with the following command:

scalac -cp。:* AcmeTrigger.scala

在具有 .scala 文件的目录中,我有一些 .jar 文件,其中包含我正在使用的电子邮件和短信服务的API。这里没有问题。

In the directory with the .scala file I have some .jar files that contain the APIs for email and texting services that I'm using. No issues here.

当有人修改数据库中的表时,scala文件实质上是发送文本消息和电子邮件。我使用以下命令启动数据库:

The scala file essentially sends text messages and emails when someone modifies a table in a database. I start the database with the following command:

java -cp。:* -jar h2-1.4.182.jar

基本上告诉它使用 .class .jar 目录中的文件,并将它们添加到类路径中。我已经做了很多变化。如果不使用.class,则使用。:*并带有完全键入的名称。不管我做什么,H2都不识别该类。

Essentially telling it to use the the .class and .jar files in directory and add them to the classpath. I've done many variations of this. Without .class, with ".:*" with the fully typed name. No matter what I do, H2 doesn't recognize the class.

因此,该数据库中存在一个将数据库连接到类的操作:

So there's an operation in this database that connects the database to a class:

在事件
上插入事件后触发触发器警报 acmeTrigger

运行此程序时,我收到一条错误消息,指出它找不到该类

创建或初始化触发器 ALERT对象,类 AcmeTrigger的错误,原因:找不到 org.h2.message.DbException:类 AcmeTrigger [90086-182]

我不认为错误出在查询语法中,但是随着我使用类路径的出现,希望有更多Java / Scala经验的人可以在这里为我提供帮助。我已经尝试了多种启动.jar文件的方法,但似乎无济于事。

I don't think the error is in the query syntax, but with how I'm using classpath's and was hoping someone with more Java/Scala experience could help me here. I've tried many variations of starting the .jar file but nothing seems to help.

推荐答案

关于默认main方法的某些事情H2 jar的结果导致奇怪的类加载器行为(需要进行更多的研究来查明原因)。我和OP有完全相同的经验。

There's something about the default main method of the H2 jar that results in strange class loader behavior (more research needed to pinpoint what). I had the exact same experience as OP.

将已编译的类复制到您选择的目录(例如 libs )以及H2 jar之后,像这样运行H2服务器:

After copying the compiled class into your directory of choice (e.g. libs), as well as the H2 jar, run the H2 server like this:

java -cp /libs:/libs/h2-1.4.197.jar org.h2。 tools.Server

这应导致触发器引用的类的正确解析。

This should result in correct resolution of the class referenced by the trigger.

这篇关于基于Java的H2数据库无法在CLASSPATH中找到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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