[英]Swagger package javax.validation.constraints does not exist
I'm having trouble building swagger Java clients using swagger-codegen
and Maven. 我在使用
swagger-codegen
和Maven构建swagger Java客户端时遇到了麻烦。 It's building on my CI using Java 1.8 and Maven 3.6. 它基于Java 1.8和Maven 3.6在CI上构建。 I'm seeing this:
我看到了这个:
... package javax.validation.constraints does not exist
... package javax.validation does not exist
The relevant part of my config is: 我的配置的相关部分是:
{
"library": "resttemplate",
"configOptions": {
"dateLibrary": "java8"
},
"useBeanValidation": true
}
And the command I use to generate the api is: 我用来生成api的命令是:
java -jar swagger-codegen-cli.jar generate -i swagger.json -l java -o ./generated/ -c swagger-java-config.json
I would expect this error to occur with Java 11. Also, I don't see the required imports in the official resttemplate
library pom.xml
template for the Java client . 我希望Java 11会发生此错误。此外,我在Java客户端的官方
resttemplate
库pom.xml
模板resttemplate
不到所需的导入。
The problem comes from "useBeanValidation": true
in the configuration. 问题来自
"useBeanValidation": true
在配置中为"useBeanValidation": true
。 This option is only available for generated servers, not clients. 此选项仅适用于生成的服务器,而不适用于客户端。 The
java -jar swagger-codegen.jar config-help -L java
will show this option as it does not discriminate on the library
chosen (in your case resttemplate
). java -jar swagger-codegen.jar config-help -L java
将显示此选项,因为它与所选择的library
没有区别(在您的情况下为resttemplate
)。 The templates specific to resttemplate
do not alter the code outputted by the java
language templates. 专用于
resttemplate
的模板不会更改java
语言模板输出的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.