dreamhead / moco

Easy Setup Stub Server
MIT License
4.37k stars 1.08k forks source link

加载配置文件无法使用*.json #339

Closed charming-cc closed 1 year ago

charming-cc commented 1 year ago

10 10月 2023 10:52:30 [main] INFO Unrecognized field: Unrecognized field "include" (class com.github.dreamhead.moco.parser.model.SessionSetting), not marked as ignorable (8 known properties: "response", "redirectTo", "mount", "proxy", "request", "websocket", "on", "resource"]) at [Source: (String)"[ {"include": "*.json"} ]"; line: 2, column: 18] (through reference chain: java.util.ArrayList[0]->com.github.dreamhead.moco.parser.model.SessionSetting["include"]) 10 10月 2023 10:52:30 [main] ERROR Unrecognized field [ include ], please check!

charming-cc commented 1 year ago
image

文档写的这种方式无法使用,必须指定json文件名字,而不是通用的所有文件

dreamhead commented 1 year ago

You should use -g option.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -g settings.json
charming-cc commented 1 year ago
image

还是一样的,当我的配置文件中指定了文件名,就不会出现这错误

dreamhead commented 1 year ago

I figure out what's wrong: you put global setting and configuration files in same directory. Moco loads global setting file as configuration file.

The simple solution is to put configuration file in separated directory, e.g foo:

[
  {
    "include": "foo/*.json"
  }
]
charming-cc commented 1 year ago

The problem has been solved,thanks