且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

OSGi:javax.annotation冲突:Java SE与Java EE

更新时间:2022-06-26 07:53:00

Java的一个重大问题是越来越多的软件包被放入JDK应该是具有自己的版本生命周期的独立项目。这不会导致单一项目中出现问题,但会在OSGi中造成痛苦。

One of the big issues of Java is that more and more packages are put into the JDK that should be standalone project with its own versioning lifecycle. This does not cause a problem in monoholitic projects, but makes a pain within OSGi.

这就是为什么我们只添加JDK中真正需要的系统包而我们从捆绑中获取所有内容。您会惊讶地发现JDK实际需要多少包。

That is why we only add the system packages that are truly necessary from the JDK and we get everything from bundles. You will be surprised how much packages you actually need from the JDK.

如果有org.osgi.framework.system.packages.exclude系统,可以快速修复属性,但遗憾的是它不存在。

A quick fix could be if there was an org.osgi.framework.system.packages.exclude system property but sadly it does not exist.

如果指定 org.osgi.framework.system.packages 且没有包,则缓慢的解决方案是并且你会逐个找到你真正需要的包裹。如果你需要更少的软件包,你会感到惊讶。

A slow solution is if you specify the org.osgi.framework.system.packages with no packages and you find one-by-one which package you actually need. You will be surprised how less packages you will need.

如果你进入felix.jar,一个更快但更脏的解决方案是找到 default.properties 并复制出 org.osgi.framework.system.packages 系统属性的内容,但不包括 javax.annotation。* 类。当你意识到你将遇到与 javax.transaction。* 包相同的问题时,你需要得到 javax.sql。* 包来自捆绑...

A quicker but more dirty solution is if you get into felix.jar, find default.properties and copy out the content of the org.osgi.framework.system.packages system property with the exclusion of javax.annotation.* classes. By the time you will realize that you will have the same issue with javax.transaction.* packages and as an outcome, you will need to get javax.sql.* packages from a bundle...

遗憾的是,在felix中,您必须在系统包列表中列出osgi-core包。使用Equinox,不必列出这些软件包(在我看来这是好的,因为osgi-core软件包不应该是系统软件包配置的一部分)。

Sadly in felix you must list the osgi-core packages as well in the list of system packages. With Equinox, those packages do not have to be listed (which is good in my opinion as osgi-core packages should not be part of system packages configuration).