You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将MuleSoft Exchange资产类型设为rest-api而非app?

解决方案:将Exchange资产设置为rest-api类型

你的错误源于用mule-maven-plugin的cloudhub2Deployment配置来发布API资产——这个配置是用来部署Mule应用到CloudHub的,默认会把资产类型标记为app,而你需要发布REST API资产到Exchange,得用专门的exchange-maven-plugin。

操作步骤:

  1. 移除mule-maven-plugin中的CloudHub部署配置
    把原配置里的<cloudhub2Deployment>块删掉,这个模块只负责应用部署,和Exchange API资产发布无关。

  2. 添加exchange-maven-plugin配置
    在pom.xml中新增该插件,明确指定资产类型为rest-api,并配置API定义文件路径等参数:

    <plugin>
        <groupId>org.mule.tools.maven</groupId>
        <artifactId>exchange-maven-plugin</artifactId>
        <version>1.12.0</version> <!-- 使用与你的Mule版本兼容的最新版本 -->
        <executions>
            <execution>
                <id>publish-api-to-exchange</id>
                <phase>deploy</phase>
                <goals>
                    <goal>publish</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <assetType>rest-api</assetType> <!-- 核心配置:指定资产类型为rest-api -->
            <apiVersion>1.0.0</apiVersion> <!-- 你的API版本号 -->
            <server>anypoint-exchange-v3</server> <!-- 对应settings.xml中配置的Exchange服务器ID -->
            <businessGroup>AAAA</businessGroup>
            <businessGroupId>*********</businessGroupId>
            <assetId>test-app2023-api</assetId> <!-- Exchange中显示的资产ID -->
            <assetName>Test App 2023 REST API</assetName> <!-- 资产名称 -->
            <mainFile>src/main/resources/api/api-definition.raml</mainFile> <!-- 你的API定义文件路径(RAML/OAS都支持) -->
            <properties>
                <anypoint.platform.base_uri>https://anypoint.mulesoft.com/</anypoint.platform.base_uri>
                <anypoint.platform.client_id>****</anypoint.platform.client_id>
                <anypoint.platform.client_secret>****</anypoint.platform.client_secret>
            </properties>
        </configuration>
    </plugin>
    
  3. 保留mule-maven-plugin的基础配置
    原插件中<sharedLibraries>和<classifier>部分可以保留,用于构建Mule应用包:

    <plugin>
        <groupId>org.mule.tools.maven</groupId>
        <artifactId>mule-maven-plugin</artifactId>
        <version>${mule.maven.plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
            <sharedLibraries>
                <sharedLibrary>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>mssql-jdbc</artifactId>
                </sharedLibrary>
            </sharedLibraries>
            <classifier>mule-application</classifier>
        </configuration>
    </plugin>
    

关键说明:

  • 确保你的项目根目录下存在API定义文件(RAML或OpenAPI规范),路径要和<mainFile>配置一致。
  • 如果需要同时部署应用到CloudHub,可单独执行mvn mule:deploy命令,而mvn deploy会自动触发Exchange API资产的发布。

内容的提问来源于stack exchange,提问作者Lex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 07:55:18