gpt4 book ai didi

java - 错误: Could not find or load main class Swagger Codegen

转载 作者:行者123 更新时间:2023-11-30 02:52:04 28 4
gpt4 key购买 nike

我为 here 留下了一个 Unresolved 问题

<小时/>

我正在尝试创建一个自定义代码生成器,我设法通过将文件放入代码生成器项目中来使其工作,但我希望它像这样工作:https://github.com/swagger-api/swagger-codegen#making-your-own-codegen-modules

我根本没有修改自动生成的项目,但我不断收到:

Error: Could not find or load main class io.swagger.codegen.SwaggerCodegen

这是命令行:

java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation 

我从这里得到了 jar https://mvnrepository.com/artifact/io.swagger/swagger-codegen-project/2.1.6这就是我正在做的事情:

  1. 运行java -jar swagger-codegen-cli-2.1.6.jar meta\-o output/myLibrary -n myClientCodegen -p com.my.company.codegen来创建服装代码生成

  2. 在output/myLibrary中运行mvn package

  3. 运行java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen 生成-i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation 在包含 swagger 的文件夹中-codege-cli-2.1.6.jar 和输出文件夹

如果我删除第一部分,它确实会找到该类,但找不到新语言:

java -cp swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation 

我已经查看了“错误:无法找到或加载主类”问题的答案,但尚未设法修复它。

Here is a link to the jar

最佳答案

对于 Windows,将类路径中的 jar 之间的冒号 (:) 更改为分号 (;)。所以而不是

java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation

应该是

java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar;swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation

多个类路径需要用分号分隔。 http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

关于java - 错误: Could not find or load main class Swagger Codegen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38334597/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com