java 9 中 javax.activation 包的替代品是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46493613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 02:23:01  来源:igfitidea点击:

What is the replacement for javax.activation package in java 9?

javajvmjava-9javax.activation

提问by Dmitriy Dumanskiy

Seems like javax.activationpackage is deprecated in Java 9. Oracle migration guide proposes to use --add-modules java.activationoption during JVM start.

似乎javax.activation包在 Java 9 中已弃用。Oracle 迁移指南建议--add-modules java.activation在 JVM 启动期间使用选项。

However, I would like to avoid this and replace javax.activationpackage's classes, as it is deprecated and will be removed in future java versions. I suppose, there should be some kind of alternative for javax.activation. If there is any available, what is it?

但是,我想避免这种情况并替换javax.activation包的类,因为它已被弃用并将在未来的 Java 版本中删除。我想,对于javax.activation. 如果有可用的,它是什么?

采纳答案by Naman

JavaBeans Activation Framework (JAF)is possibly the alternative you are looking for to the existing package.

JavaBeans Activation Framework (JAF)可能是您正在寻找的现有包的替代方案。

This standalone release of JAF uses a Java Platform Module System automatic modulename of java.activation, to match the module name used in JDK 9. A future version will include full module metadata.

此独立版本的 JAF 使用 Java 平台模块系统 自动模块名称java.activation, 以匹配 JDK 9 中使用的模块名称。未来版本将包含完整的模块元数据。

The standalone APIs are supported in modular form only, via the concept of upgradeable modules. Using them, it's possible to use a version of that module from a later release in any phase, i.e., at compile time, build time, or runtime.

通过可升级模块的概念,仅以模块化形式支持独立 API 。使用它们,可以在任何阶段(即,在编译时、构建时或运行时)使用更高版本的该模块的版本。



The currently available versionfor this is 1.2.0which can be used like this:

当前可用的版本因为这是1.2.0它可以这样使用:

Maven

马文

<dependency>
    <groupId>com.sun.activation</groupId>
    <artifactId>javax.activation</artifactId>
    <version>1.2.0</version>
</dependency>

Gradle

摇篮

compile 'com.sun.activation:javax.activation:1.2.0'

Ivy

常春藤

<dependency org="com.sun.activation" name="javax.activation" rev="1.2.0" />

回答by Alan Bateman

The JavaBeans Activiation Framework is a standalone technology with its own maintenance JSR in the JCP and its own download. Yes, Java SE 9 has deprecated it and has proposes to remove in a future release along with the modules shared with Java EE but this doesn't impact the standalone version. The standalone version will live on. If you are using Maven then this should work:

JavaBeans Activation Framework 是一种独立的技术,在 JCP 中有自己的维护 JSR 和自己的下载。是的,Java SE 9 已弃用它,并建议在未来的版本中连同与 Java EE 共享的模块一起删除,但这不会影响独立版本。独立版本将继续存在。如果您使用的是 Maven,那么这应该可以工作:

<dependency>
  <groupId>com.sun.activation</groupId>
  <artifactId>javax.activation</artifactId>
  <version>1.2.0</version>
</dependency>

and if you are developing a module then you can requires java.activation.

如果你正在开发一个模块,那么你可以requires java.activation

回答by Michal Cz

As written above, java versions > 8 are not providing javax.activation. I met this exception when working on camel project. I've just added the following dependency:

如上所述,java 版本 > 8 不提供 javax.activation。我在进行骆驼项目时遇到了这个异常。我刚刚添加了以下依赖项:

<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>