英文:
Attribute value must be a constant in SwaggerConfig
问题
我已经为一个类配置了Swagger,但在使用常量创建基本路径时出现错误,
public static final String paymentControllerBasePath = "cx/payment/v1";
public static final String payoutControllerBasePath = "cx/payment/v1";
如果我尝试在类中导入它们,如下所示,
@Api(tags = { paymentControllerBasePath }, value = "payment functionality", produces = "application/json")
上面一行中的tags值在IntelliJ中显示错误,
Attribute value must be constant
嗯,它确实是一个常量。有人能帮我解决这个错误吗?
英文:
I have swagger configured for a class and the error for creating base path using constants,
public static final String paymentControllerBasePath = "cx/payment/v1"
public static final String payoutControllerBasePath = "cx/payment/v1"
If I try to import them into a class, like,
@Api(tags = { paymentControllerBasePath }, value = "payment functionality", produces = "application/json")
The tags value in the above line shows an error in IntelliJ saying
Attribute value must be constant
Well, it is a constant. Can anyone help me mitigate this error?
答案1
得分: 1
请使用字符串字面值。注解不接受变量或常量变量。
编译时常量仅限于原始数据类型。并且注解不接受运行时变量或常量。
英文:
Please use string literals. Annotations don’t accept variables or constant variables.
Compile time constants are primitive data types only. And annotations don’t accept runtime variables or constants.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论