2017-10-12 142 views
0

我正在使用raml第一次使用我的raml文件,如下所示。如何使用raml?

#%RAML 0.8 
title: Contact 
version: 1 
baseUri: http://abc/api/{version} 
traits: 
    - client-id-required: 
     queryParameters: 
     client_id: 
      type: string 
     client_secret: 
      type: string 
/contact: 
    post: 
    is: [client-id-required] 
    description: Create a new contact record 
    body: 
     application/json: 
     example: !include contactCreateReq_sample.json 
     schema: !include contactCreateReq.json 
    responses: 
     200: 
     body: 
      application/json: 
      example: !include contactCreateRes_sample.json 
      schema: !include contactCreateRes.json 
    put: 
    is: [client-id-required] 
    description: update a customer record 
    body: 
     application/json: 
     example: !include contactUpdateReq_sample.json 
     schema: !include contactUpdateReq.json 
    responses: 
     200: 
     body: 
      application/json: 
      example: !include contactUpdateRes_sample.json 
      schema: !include contactUpdateRes.json 
    delete: 
    is: [client-id-required] 
    description: update a customer record 
    body: 
     application/json: 
     example: !include contactUpdateReq_sample.json 
     schema: !include contactUpdateReq.json 
    responses: 
     200: 
     body: 
      application/json: 
      example: !include contactUpdateRes_sample.json 
      schema: !include contactUpdateRes.json  
    /{functionId}: 
    post: 
     is: [client-id-required] 
     description: Create a new contact function record 
     responses: 
     200: 
      body: 
      application/json: 
       example: !include contactCreateReq_sample.json 
       schema: !include contactCreateReq.json 
    put: 
     is: [client-id-required] 
     description: Update an existing contact function record 
     responses: 
     200: 
      body: 
      application/json: 
       example: !include contactUpdateRes_sample.json 
       schema: !include contactUpdateRes.json 

收到以下错误信息,同时运行我们的界面,我有几个肾错构瘤的文件获得相同类型的错误在所有的错构瘤文件中的个案。它正在生产工作接口,我试图在我的本地机器上运行,并得到了提及的错误。请让我知道我的代码中缺少任何内容?

ERROR 2017-10-12 13:02:26,292 [main] org.mule.module.launcher.application.DefaultMuleApplication: null 
org.mule.module.apikit.exception.ApikitRuntimeException: Invalid API descriptor -- errors found: 1 

RAML resource not found -- file: contact.raml 

    at org.mule.module.apikit.parser.ParserWrapperV1.validate(ParserWrapperV1.java:68) ~[mule-module-apikit-3.8.5-HF1.jar:?] 
    at org.mule.module.apikit.ParserService.validateRaml(ParserService.java:86) ~[mule-module-apikit-3.8.5-HF1.jar:?] 
    at org.mule.module.apikit.AbstractConfiguration.initialise(AbstractConfiguration.java:112) ~[mule-module-apikit-3.8.5-HF1.jar:?] 
    at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) ~[?:?] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] 
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] 
    at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:237) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.lifecycle.phases.MuleContextInitialisePhase.applyLifecycle(MuleContextInitialisePhase.java:71) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.lifecycle.RegistryLifecycleCallback.doApplyLifecycle(RegistryLifecycleCallback.java:99) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.lifecycle.RegistryLifecycleCallback.onTransition(RegistryLifecycleCallback.java:71) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:155) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:126) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.registry.AbstractRegistry.fireLifecycle(AbstractRegistry.java:146) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:116) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:177) ~[mule-module-spring-config-3.8.5.jar:3.8.5] 
    at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:100) ~[mule-module-spring-config-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:43) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:102) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:54) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:43) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:89) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81) ~[mule-core-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:203) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:63) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:58) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:317) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:172) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:261) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:76) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:279) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:151) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:134) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:172) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] 
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] 
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:33) ~[tooling-support-3.8.5.jar:?] 
INFO 2017-10-12 13:02:26,292 [main] org.mule.module.launcher.application.DefaultMuleApplication: App 'sfdc-sap-api-interface-v4.7-prod' never started, nothing to dispose of 
ERROR 2017-10-12 13:02:26,307 [main] org.mule.module.launcher.DefaultArchiveDeployer: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
+ Failed to deploy artifact        + 
+ 'sfdc-sap-api-interface-v4.7-prod', see below   + 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
org.mule.module.launcher.DeploymentInitException: ApikitRuntimeException: Invalid API descriptor -- errors found: 1 

RAML resource not found -- file: contact.raml 

    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:212) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:63) ~[mule-module-launcher-3.8.5.jar:3.8.5] 
    at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136) ~[mule-module-launcher-3.8.5.jar:3.8.5] 

回答

1

这样的错误来了,如果ram文件不在类路径中,而应用程序正在构建。

A。如果您正在使用Anypoint Studio构建

1.转至Java构建路径在您的项目属性中。

2.Click “来源” 选项卡上

3.Click上添加文件夹按钮。

4.检查存在“contact.raml”的文件夹。通常raml文件夹保存在“api”文件夹中。因此,如果是这样,请检查“api”文件夹并点击“OK”。

5.Click “应用

添加的文件夹,其中“contact.raml”是存在的。通常raml文件夹保存在“api”文件夹中。因此,如果是这样,请检查“api”文件夹并单击“确定”。之后清理并重建项目。

。如果你是使用Maven构建项目

请确保您在pom文件中具有“mule-module-apikit”依赖项,如果不添加它并在插件中指定资源目录,请尝试下面的代码。考虑以下来自我的pom.xml的示例

<groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.7</version> 
     <executions> 
      <execution> 
       <id>add-resource</id> 
       <phase>generate-resources</phase> 
       <goals> 
        <goal>add-resource</goal> 
       </goals> 
       <configuration> 
        <resources> 
         <resource> 
          <directory>src/main/app/</directory> 
         </resource> 
         <resource> 
          <directory>mappings/</directory> 
         </resource> 
         <resource> 
          <directory>src/main/api</directory> 
         </resource> 
        </resources> 
       </configuration> 
      </execution> 
     </executions> 
    </plugin>