在哪里可以找到Jakarta EE 9或10兼容JAXB参考实现JAR文件?

发布于 2025-01-27 04:13:21 字数 231 浏览 2 评论 0原文

因此,我有一个使用一些Javax的小JAR应用程序(不在Web容器中运行)。*在JDK8上运行的JAXB类。 现在是升级到JDK17的时候,该JDK17不与Jaxb一起运送。 因此,我认为,很容易,我下载了jaxb的jakarta EE 9(或10)参考实现JAR文件,在代码Javax中切换。 似乎我找不到可以在jakarta EE 9(或10)中下载JAXB的参考实现JAR文件的位置。 所以显然我缺少一些东西。 有人可以指导我解决这个问题吗?

So I have a small JAR application (not running in a web container) that uses some javax.* classes of JAXB running on jdk8.
The time has come to upgrade to jdk17 which does not ship with JAXB.
So I thought,easy enough, I download the jakarta ee 9 (or 10) reference implementation jar files for JAXB, switch in the code javax.* to jakarta.* namespace and we are good to go.
Seems I can't find where I can download the reference implementation jar files for JAXB in jakarta ee 9 (or 10).
So obviously I'm missing something.
Can someone guide me to the good approach to solve this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆啦不做梦 2025-02-03 04:13:21

我主要使用Maven来处理我的依赖项,但希望这至少有所帮助。

对于JAXB 3.X,您可以使用以下API依赖性,

<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>3.0.1</version>
</dependency>

然后用于实现,您可以使用以下内容。

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>3.0.0</version>
</dependency>

如果您需要从XSD生成类,则可以使用Jaxb2-Maven-Plugin 3.1.0。它似乎仅取决于jakarta.xml.bind-api,同时将休息作为嵌套依赖关系。

<!-- 
  by default searches schemas from src/main/xsd 
  and binding files from src/main/xjb
-->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <packageName>com.example.api</packageName>
    </configuration>
</plugin>

不确定javax.crivation

I mostly use maven to handle my dependencies but hope this helps at least a bit.

For jaxb 3.x you can use following api-dependency

<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>3.0.1</version>
</dependency>

Then for implementation you can use the following.

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>3.0.0</version>
</dependency>

If you need to generate classes from xsd you can use jaxb2-maven-plugin 3.1.0. It seems to only depend on jakarta.xml.bind-api while including rest as nested dependencies.

<!-- 
  by default searches schemas from src/main/xsd 
  and binding files from src/main/xjb
-->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <packageName>com.example.api</packageName>
    </configuration>
</plugin>

Not sure about javax.activation

想念有你 2025-02-03 04:13:21

这与问题无直接相关,但这对于想要更新软件包名称javax jakarta的人可能会有所帮助。如果您有很多项目包含很多课程,那么用替换器将其转换成真是无聊。取而代之的是,您有2个选项:

选项1

在您的项目root文件夹中执行Shell脚本,并让脚本自动为您转换。但是,您必须修改Shell脚本以覆盖所有软件包。

您可以在此文章

选项2

如果您使用的是Intellij Idea,那么您很幸运,有一个按钮可以转换所有软件包。

重构&gt;迁移软件包和类&gt; Java EE到Jakarta EE

请按照上述路径查找选项。

This is not directly related to the question, but it can be helpful for people who wants to update package names javax to jakarta. If you have huge project contains lots of classes, then it will be really boring to convert them with replacer. Instead, you have 2 options:

Option 1

Execute shell script in your project root folder and let the script converts automatically for you. However, you have to modify the shell script to cover all the packages.

You can find the script in this article.

Option 2

If you are using Intellij IDEA, then you are lucky, there is a button to convert all packages.

Refactor > Migrate Packages and Classes > Java EE to Jakarta EE

Follow the above path to find the option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文