gpt4 book ai didi

java - 由 : java. lang.ClassNotFoundException : net. com.myproject.core 找不到 sf.json.xml.XMLSerializer 引起 [35154]

转载 作者:太空宇宙 更新时间:2023-11-04 15:08:06 24 4
gpt4 key购买 nike

我使用json-lib将xml结构转换为json格式。我的依赖项如下所示:

 <dependencies>

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>

<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>

<!-- XML -->
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.0</version>
</dependency>

</dependencies>

在下面一行:

 XMLSerializer xmlSerializer = new XMLSerializer();

编译器抛出愚蠢的错误:

Caused by: java.lang.ClassNotFoundException: net.sf.json.xml.XMLSerializer not found by com.myproject.core

知道为什么我会收到此错误吗?

最佳答案

我通过将缺少的 jar 添加到 maven-bundle-plugin 嵌入依赖项来解决问题

           <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>
..
.....
json-lib,
xom,
ezmorph,
commons-collections,
commons-beanutils,
.....
</Embed-Dependency>
.............

关于java - 由 : java. lang.ClassNotFoundException : net. com.myproject.core 找不到 sf.json.xml.XMLSerializer 引起 [35154],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21710402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com