运行 测试时出错:无法找到命名空间 [http://www.mulesoft.org/schema/mule/oauth2] 的 NamespaceHandler

Error when running tests: Unable to locate NamespaceHandler for namespace [http://www.mulesoft.org/schema/mule/oauth2]

当我 运行 应用程序(有 Maven 支持)时,它工作正常,但是当我 运行 mvn test(功能测试)时它给我错误:Unable to locate NamespaceHandler for namespace [http://www.mulesoft.org/schema/mule/oauth2]

好像是从这里来的:

<http:request-config name="ApiRest" protocol="HTTPS" doc:name="HTTP Request Configuration" basePath="rest" host="${api.endpointUrl}" port="443"> <oauth2:client-credentials-grant-type clientId="${api.client_id}" clientSecret="${api.client_secret}"> <oauth2:token-request tokenUrl="${api.endpointUrl}/oauth/token" /> </oauth2:client-credentials-grant-type> </http:request-config>

到底哪里出了问题?

我之前遇到过类似的问题,但它抱怨 spring-ss 命名空间。看看同样的解决方案是否适用于您。

将这些 jar 添加到您的 pom.xml 中,它们可能负责该命名空间。

<dependency>
    <groupId>com.mulesoft.muleesb.modules</groupId>
    <artifactId>mule-module-boot-ee</artifactId>
    <version>${mule.version}</version>
</dependency>
<dependency>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-ws</artifactId>
    <version>${mule.version}</version>
    <scope>provided</scope>
</dependency>

也许也值得尝试 mule-module-oauth 模块。

祝你好运!