Java light-4j:light codegen无法生成项目

Java light-4j:light codegen无法生成项目,java,microservices,light-4j,Java,Microservices,Light 4j,我已经尝试使用提供的示例petstore openapi.json生成项目。我曾经生成端点和模型 我确实安装了light codegen: git clone https://github.com/networknt/light-codegen.git cd light-codegen mvn clean install 然后从项目文件夹运行codegen: java -jar ../../networknt/light-codegen/codegen-cli/target/codegen-c

我已经尝试使用提供的示例petstore openapi.json生成项目。我曾经生成端点和模型

我确实安装了light codegen:

git clone https://github.com/networknt/light-codegen.git
cd light-codegen
mvn clean install
然后从项目文件夹运行codegen:

java -jar ../../networknt/light-codegen/codegen-cli/target/codegen-cli.jar -f openapi -o /tmp/petstore -m openapi.json -c config.json
我在输出中看到以下错误:

openapi openapi.json config.json /tmp/petstore
19:16:00.766 [main] INFO com.networknt.config.Config - daily config cache refresh
19:16:00.772 [main] INFO com.networknt.config.Config - Unable to load config from externalized folder for service.yml in 
19:16:00.772 [main] INFO com.networknt.config.Config - Trying to load config from classpath directory for file service.yml
19:16:00.774 [main] INFO com.networknt.config.Config - Config loaded from default folder for service.yml
19:16:04.799 [main] INFO com.fizzed.rocker.runtime.RockerRuntime - Rocker version 0.22.0
19:16:04.801 [main] INFO com.fizzed.rocker.runtime.RockerRuntime - Rocker template reloading not activated
java.nio.file.NoSuchFileException: /tmp/petstore/src/test/resources/config/client.keystore
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
    at java.nio.file.Files.newOutputStream(Files.java:216)
    at java.nio.file.Files.copy(Files.java:3016)
    at com.networknt.codegen.rest.OpenApiGenerator.generate(OpenApiGenerator.java:367)
    at com.networknt.codegen.Cli.run(Cli.java:98)
    at com.networknt.codegen.Cli.main(Cli.java:50)
我是否需要以某种方式提供client.keystore?

config.json

{
  "name": "petstore",
  "version": "3.0.1",
  "groupId": "com.networknt",
  "artifactId": "petstore",
  "rootPackage": "com.networknt.petstore",
  "handlerPackage":"com.networknt.petstore.handler",
  "modelPackage":"com.networknt.petstore.model",
  "overwriteHandler": true,
  "overwriteHandlerTest": true,
  "overwriteModel": true,
  "httpPort": 8080,
  "enableHttp": false,
  "httpsPort": 8443,
  "enableHttps": true,
  "enableHttp2": true,
  "enableRegistry": false,
  "supportDb": false,
  "supportH2ForTest": false,
  "supportClient": false,
  "specChangeCodeReGenOnly": true,
  "dockerOrganization": "networknt"
}

openapi.json:

在配置中,supportClient设置为false。在这种情况下,不需要生成client.keystore。我猜这就是目录问题

如果您想在openapi中生成petstore项目,那么最好的方法是从您的工作区运行生成器,其中包含light codegen和model config作为子文件夹。

java-jar-light-codegen/codegen-cli/target/codegen-cli.jar-f openapi-o/tmp/petstore-m model-config/rest/openapi/petstore/1.0.0/openapi.json-c model-config/rest/openapi/petstore/1.0.0/config.json
带有maven/petstore spec/config的light-example-4j/rest/petstore中的配置不是用于从命令行生成代码,而是用于从maven插件生成代码

如果您想从该文件夹生成代码,下面是命令行


java-jar-light-codegen/codegen-cli/target/codegen-cli.jar-f openapi-o/tmp/petstore-m light-example-4j/rest/perstore with codegen/petstore spec/config/openapi.yaml-c light-example-4j/rest/perstore with codegen/petstore spec/config/config.json

我已经尝试了这两个命令,它们都在我的桌面上运行良好。让我详细了解您的步骤,以便我可以复制该问题。谢谢

在配置中,supportClient设置为false。在这种情况下,不需要生成client.keystore。我猜这就是目录问题

如果您想在openapi中生成petstore项目,那么最好的方法是从您的工作区运行生成器,其中包含light codegen和model config作为子文件夹。

java-jar-light-codegen/codegen-cli/target/codegen-cli.jar-f openapi-o/tmp/petstore-m model-config/rest/openapi/petstore/1.0.0/openapi.json-c model-config/rest/openapi/petstore/1.0.0/config.json
带有maven/petstore spec/config的light-example-4j/rest/petstore中的配置不是用于从命令行生成代码,而是用于从maven插件生成代码

如果您想从该文件夹生成代码,下面是命令行


java-jar-light-codegen/codegen-cli/target/codegen-cli.jar-f openapi-o/tmp/petstore-m light-example-4j/rest/perstore with codegen/petstore spec/config/openapi.yaml-c light-example-4j/rest/perstore with codegen/petstore spec/config/config.json

我已经尝试了这两个命令,它们都在我的桌面上运行良好。让我详细了解您的步骤,以便我可以复制该问题。谢谢

谢谢你,史蒂夫。当我设置“supportClient”:true时,问题就消失了,toll确实生成了项目。顺便说一句,我没有本地模型配置项目。我猜当“supportClient”设置为false时,可能是codegen工具的一个bug?我还注意到生成的项目文件夹不包含pom.xml build。仅存在src子文件夹。在上面的第二句话中,我在light-example-4j中使用openapi.yaml和config.json,没有任何问题。您能详细描述一下这些步骤吗?这样我就可以在本地计算机上进行复制了?谢谢,谢谢你,史蒂夫。当我设置“supportClient”:true时,问题就消失了,toll确实生成了项目。顺便说一句,我没有本地模型配置项目。我猜当“supportClient”设置为false时,可能是codegen工具的一个bug?我还注意到生成的项目文件夹不包含pom.xml build。仅存在src子文件夹。在上面的第二句话中,我在light-example-4j中使用openapi.yaml和config.json,没有任何问题。您能详细描述一下这些步骤吗?这样我就可以在本地计算机上进行复制了?谢谢