用于MATLAB的Java JPA类 [英] Java JPA Class for MATLAB

查看:121
本文介绍了用于MATLAB的Java JPA类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows XP Pro SP3上使用MATLAB R2007b,Java 1.6 SE,Eclipse Helios和MySql 5.

I'm using MATLAB R2007b, Java 1.6 SE, Eclipse Helios, and MySql 5 on Windows XP Pro SP3.

我正在尝试创建一个类库使用JPA注释访问MySql 5数据库。我们的想法是MATLAB脚本实例化这些Java对象,它们提供了一个访问数据库的API。

I'm trying to create a class library that uses JPA annotations to access a MySql 5 database. The idea is that the MATLAB script instantiates these Java objects, which provide an API for accessing the DB.

我可以创建带注释的类,它们在Eclipse中工作(即JUnit)测试)。我可以将代码导出到jar,我可以从命令提示符运行。

I can create my annotated classes, which work within Eclipse (i.e. JUnit test). I can export the code to a jar, which I can run from a command prompt.

我使用javaaddpath()更新MATLAB Java类路径。我可以在MATLAB中实例化我的类。但是,当我调用我的init(),它调用javax.persistence.Persistence.createEntityManagerFactory()时,我得到了可怕的

I update the MATLAB Java classpath using javaaddpath(). I can instantiate my class within MATLAB. But when I call my init(), which calls javax.persistence.Persistence.createEntityManagerFactory(), I get the dreaded

没有EntityManager的持久性提供程序

"No Persistence provider for EntityManager"

此错误通常意味着persistence.xml文件不在正确的位置。但它必须是因为我的jar从命令行工作。将META-INF文件夹添加到MATLAB java类路径中没有帮助。也不提取jar并将提取的文件夹结构添加到类路径中,无论是否添加了META-INF。

This error usually means that the persistence.xml file isn't in the right place. But it must be because my jar works from the command line. Adding the META-INF folder to the MATLAB java classpath doesn't help. Nor does extracting the jar and adding the extracted folder structure to the classpath, whether or not META-INF is added.

有没有人有任何想法,坚果与否?有没有人在任何版本的MATLAB中做过这个。

Does anyone have any ideas, nutty or not? Has anyone ever done this in any version of MATLAB.

谢谢。

-reilly。

推荐答案

在MATLAB中使用Java时,我经常遇到动态类路径的问题。作为一种解决方法,使用 classpath.txt 到目前为止已解决了任何问题。

While working with Java in MATLAB, I often encountered issues with the dynamic classpath. As a workaround, using classpath.txt has solved any issue so far.

处理不同的环境,例如测试和生产,会在MATLAB中产生多个 classpath.txt 文件目录。使用不同的MATLAB版本会增加另一个乘以 classpath.txt 文件的数量。

Dealing with different environments, for example testing and production, results in multiple classpath.txt files in your MATLAB start directory. Using different MATLAB releases adds another multiplier to the number of classpath.txt files around.

ClassPathHacker .java 是一个将动态类和jar文件添加到静态类路径的选项。使用此方法,无需再触摸 classpath.txt 。您的Java类路径配置可以保留在预定的位置 startup.m

ClassPathHacker.java is an option to add dynamically classes and jar files to your static classpath. Using this approach there is no need to touch classpath.txt anymore. Your Java classpath configuration can stay in the intended place startup.m.

这篇关于用于MATLAB的Java JPA类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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