访问 Maven 项目中 XMLBeans 生成的 schemas.jar
我有一个 schemas.jar
提供给我,并尝试从一个简单的 Maven 项目中访问它。我已将 schemas.jar
文件放入 src/main/resources
目录中,该目录位于我的类路径中。
当我尝试使用以下内容访问创建的文档时:
GetOrdersRequestDocument getOrdersRequestDocument = GetOrdersRequestDocument.Factory.newInstance();
它抱怨 GetOrdersRequestDocument
(找不到它)。
我如何让项目学习这些课程?我需要导入任何特定的东西吗?
I have a schemas.jar
supplied to me and am trying to access it from within a simple Maven project. I have put the schemas.jar
file in my src/main/resources
directory, which is in my classpath.
When I am trying to access the created documents with something like:
GetOrdersRequestDocument getOrdersRequestDocument = GetOrdersRequestDocument.Factory.newInstance();
It complains about the GetOrdersRequestDocument
(can't find it).
How do I get the project to pick up these classes? Do I need to import anything specific?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
src/main/resources
目录中的文件位于您的类路径中。但这并不意味着jar本身的内容是直接可用的。您可以使用URLClassLoader
来加载 JAR。但是……这不是我做事的方式。如果这是一个选项,我只需将 JAR 安装在您的公司或本地存储库中(使用
install:install-file
) 并将其声明为依赖项。这将使 JAR 的内容可供您的代码使用,就像任何其他依赖项一样。Yes, the files in
src/main/resources
directory are on your classpath. But this doesn't mean that the content of the jar itself is directly available. You could use aURLClassLoader
to load the JAR though.But... this is not how I would do things. If this is an option, I would just install the JAR in your corporate or local repository (using
install:install-file
) and declare it as a dependency. This would make the content of your JAR available to your code, like any other dependency.