为什么选择Jigsaw / JPMS? [英] Why project Jigsaw / JPMS?

查看:118
本文介绍了为什么选择Jigsaw / JPMS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java的包管理系统对我来说似乎总是简单而有效。 JDK本身大量使用它。我们一直在使用它来模仿命名空间和模块的概念。

Java's package management system always seemed simple and effective to me. It is heavily used by the JDK itself. We have been using it to mimic the concept of namespaces and modules.

什么是 Project Jigsaw (又名 Java平台模块系统)试图填写?

What is Project Jigsaw (aka Java Platform Module System) trying to fill in?

来自官方网站:


本项目的目标是为Java SE平台设计和实现标准模块
系统,并将该系统应用于
平台本身和JDK。

The goal of this Project is to design and implement a standard module system for the Java SE Platform, and to apply that system to the Platform itself and to the JDK.


推荐答案

<拼图和OSGi正试图解决同样的问题:如何允许粗粒度模块在屏蔽其内部时进行交互。

Jigsaw and OSGi are trying to solve the same problem: how to allow coarser-grained modules to interact while shielding their internals.

在Jigsaw的情况下,粗粒度模块包括Java类,包及其依赖项。

In Jigsaw's case, the coarser-grained modules include Java classes, packages, and their dependencies.

这是一个例子:Spring和Hibernate。两者都依赖于第三方JAR CGLIB,但它们使用该JAR的不同,不兼容的版本。如果您依赖标准JDK,您会怎么做?包括Spring希望打破Hibernate的版本,反之亦然。

Here's an example: Spring and Hibernate. Both have a dependency on a 3rd party JAR CGLIB, but they use different, incompatible versions of that JAR. What can you do if you rely on the standard JDK? Including the version that Spring wants breaks Hibernate and visa versa.

但是,如果你有像Jigsaw这样的更高级别的模型,你可以轻松管理不同版本的JAR模块。将它们视为更高级别的包。

But, if you have a higher-level model like Jigsaw you can easily manage different versions of a JAR in different modules. Think of them as higher-level packages.

如果您构建来自GitHub源的Spring 你也会看到它。他们重做了框架,因此它包含几个模块:核心,持久性等。您可以选择应用程序所需的最小模块依赖项集,而忽略其余部分。它曾经是一个Spring JAR,其中包含所有.class文件。

If you build Spring from the GitHub source you'll see it, too. They've redone the framework so it consists of several modules: core, persistence, etc. You can pick and choose the minimal set of module dependencies that your application needs and ignore the rest. It used to be a single Spring JAR, with all the .class files in it.

更新:五年之后 - Jigsaw可能还有一些问题要解决。

Update: Five years later - Jigsaw might still have some issues to resolve.

这篇关于为什么选择Jigsaw / JPMS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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