Mule 使用自定义模块运行应用程序时出现NoClassDefFoundError

Mule 使用自定义模块运行应用程序时出现NoClassDefFoundError,mule,mule-component,Mule,Mule Component,我使用Mule SDK构建了一个Mule 4模块,该模块内部使用了com.googlecode.json simple。为了创建项目,我使用了Maven原型org.mule.extensions:mule extensions原型Maven插件:1.2.0,如中所述 我能够构建项目并将其包含在Anypoint Studio 7.8中,并利用我的Mule应用程序中的操作,我可以配置它们,在UI中更新其属性,但每当我运行应用程序时,都会因java.lang.NoClassDefFoundError而

我使用Mule SDK构建了一个Mule 4模块,该模块内部使用了
com.googlecode.json simple
。为了创建项目,我使用了Maven原型
org.mule.extensions:mule extensions原型Maven插件:1.2.0
,如中所述

我能够构建项目并将其包含在Anypoint Studio 7.8中,并利用我的Mule应用程序中的操作,我可以配置它们,在UI中更新其属性,但每当我运行应用程序时,都会因
java.lang.NoClassDefFoundError
而失败,因为它找不到库

我应该做什么额外的配置来确保库在运行时可用

错误:

ERROR 2021-04-09 06:33:48,410 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer: Failed to deploy artifact [project1]
org.mule.runtime.deployment.model.api.DeploymentException: Failed to deploy artifact [project1]
Caused by: java.lang.NoClassDefFoundError: com/google/gson/JsonObject
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_232]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_232]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_232]
    at org.mule.runtime.module.extension.internal.util.IntrospectionUtils.lambda$getMethodsStream$14(IntrospectionUtils.java:923) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
    at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269) ~[?:1.8.0_232]
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[?:1.8.0_232]
    at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1556) ~[?:1.8.0_232]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_232]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_232]
模块的pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mule.extension</groupId>
    <artifactId>mule-basic-extension</artifactId>
    <version>1.0.1-SNAPSHOT</version>
    <packaging>mule-extension</packaging>
    <name>My Extension</name> 

    <parent>
        <groupId>org.mule.extensions</groupId>
        <artifactId>mule-modules-parent</artifactId>
        <version>1.1.3</version>
    </parent>

    <dependencies>
        <dependency>
           <groupId>com.googlecode.json-simple</groupId>
           <artifactId>json-simple</artifactId>
           <version>1.1.1</version>
        </dependency>
     </dependencies>

</project>

事实证明,我在项目中使用的JSON库存在问题

我替换了这个依赖项

<dependency>
  <groupId>com.googlecode.json-simple</groupId>
  <artifactId>json-simple</artifactId>
  <version>1.1.1</version>
</dependency>

com.googlecode.json-simple
简单json
1.1.1
通过这个,我能够创建返回JSON的操作

<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.8.6</version>
</dependency>

com.google.code.gson
格森
2.8.6

请提供操作Java定义的示例,以了解您使用的Java类型。
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.8.6</version>
</dependency>