Eclipse 中的 OSGi 无法解析依赖关系
我正在开发 OSGi/Equinox 插件,但似乎无法让 Hibernate 依赖项正常工作。我已经使用 Eclipse 将 Hibernate 依赖项添加到我的 POM 中,并且它已成功下载它们。
但是,我根本无法在任何项目类中使用它们 - 就好像它们甚至没有添加为依赖项一样。
为什么我不能简单地将 Hibernate 添加为依赖项,然后在我的代码中使用它? 缺少什么?
我知道这应该非常简单,并且我认为我在某个地方缺少了一些东西。如果有一点指示,我们将不胜感激。
干杯
I'm working on an OSGi/Equinox plugin and cannot seem to get the Hibernate dependencies working. I've added the Hibernate dependencies to my POM with Eclipse and it has successfully downloaded them.
However, I simply cannot use them in any project classes - as if they have not even been added as dependencies.
Why can I not simply add Hibernate as a dependency and then use it in my code? What's missing?
I know this should be really straight forward and I assume I'm missing something somewhere. A little pointer would be greatly appreciated.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您正在使用 Eclipse 插件开发环境 (PDE)?如果是这样,您需要将包
org.hibernate.cfg
(可能还有其他包)添加到您的包的导入包中(转到清单编辑器的“依赖项”选项卡)。PDE 的方法是只允许您的代码查看您首先显式导入的包。其他工具,例如 Bndtools 允许您的代码查看构建路径上的所有包,并随后生成 OSGi
Import -Package
声明基于您实际使用的内容。I assume you are using Eclipse Plug-in Development Environment (PDE)? If so, you need to add the package
org.hibernate.cfg
(and probably others) to the imported packages for your bundle (go to the Dependencies tab of the manifest editor).PDE's approach is to only allow your code to see packages that you have explicitly imported first. Other tools such as Bndtools allow your code to see all packages on the build path, and subsequently generate the OSGi
Import-Package
statement based on what you actually used.添加到 pom 后,您将其构建为 mavne 项目还是 eclipse 项目?
我的意思是首先构建为;
mvn clean install
然后创建一个 eclipse 项目
mvn eclipse:eclipse -o
然后将其导入到工作区..您将能够使用这些库
After adding to your pom you build it as mavne project or eclipse project?
I mean build first as;
mvn clean install
Then create a eclipse project
mvn eclipse:eclipse -o
Then import that to workspace ..You will be able to use the libraries