首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >light-4j: light无法生成项目

light-4j: light无法生成项目
EN

Stack Overflow用户
提问于 2018-11-19 21:25:42
回答 1查看 335关注 0票数 0

我尝试用提供的openapi.json示例生成项目。我使用光码元生成端点和模型。

我确实安装了光代码:

代码语言:javascript
复制
git clone https://github.com/networknt/light-codegen.git
cd light-codegen
mvn clean install

然后从我的项目文件夹运行codegen:

代码语言:javascript
复制
java -jar ../../networknt/light-codegen/codegen-cli/target/codegen-cli.jar -f openapi -o /tmp/petstore -m openapi.json -c config.json

我在输出中看到了以下错误:

代码语言:javascript
复制
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

代码语言:javascript
复制
{
  "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:https://github.com/networknt/light-example-4j/blob/master/rest/perstore-with-codegen/petstore-spec/config/openapi.json

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-20 01:58:12

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

如果您想在openapi中生成petstore项目,那么最好的方法是从您的工作区中运行生成器,其中的light-codegen和model-config都是子文件夹。light-example-4j/rest/petstore-with-maven/petstore-spec/config中的配置不是用于从命令行生成代码,而是用于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 --我尝试过这两个命令,它们在我的桌面上都运行得很好。让我详细了解你的步骤,这样我就可以重复这个问题了。谢谢。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53382865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档