java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

时间秒杀一切 提交于 2020-06-24 08:27:05

问题


After installing JDK9, I get this exception when running my Scala projects. Upgrading Scala to 2.12.2 also didn't resolve my problem.


回答1:


The java.xml.bind module is not resolved by default when running code on the module path. This means that if you depend on JAXB then you need to run with --add-modules java.xml.bind or else deploy JAXB on the class path (or module path).

Update: The "Modules Shared with Java EE Not Resolved by Default" section of JDK 9 Migration Guide provides more information on this topic.




回答2:


To add to the previous answer I would like to refer to the following answer: https://stackoverflow.com/a/43574427/3751268. I think it covers in details which is the desired way to provide libraries like the jaxb.

In particular for Scala, I add it like this to my libraryDependencies:

libraryDependencies += Seq("javax.xml.bind" % "jaxb-api" % "2.3.0")



回答3:


You can add dependencies in maven

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>


来源:https://stackoverflow.com/questions/42966880/java-lang-noclassdeffounderror-javax-xml-bind-datatypeconverter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!