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

查看:23
本文介绍了用于 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 中实例化我的类.但是当我调用调用 javax.persistence.Persistence.createEntityManagerFactory() 的 init() 时,我感到害怕

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.

谢谢.

-赖利.

推荐答案

在 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天全站免登陆