【问题标题】:@Import - An Annotation argument must be a compile time constant@Import - Annotation 参数必须是编译时间常数
【发布时间】:2020-02-12 12:24:00
【问题描述】:
@Configuration
@Import(UserpassportConfig::class)
class UvdConfig

您好,我的 gradle 命令有问题:“gradlew clean build” - 我收到此错误:

e: config\UvdConfig.kt: (5, 22): Unresolved reference: userpassport
e: config\UvdConfig.kt: (12, 9): Unresolved reference: UserpassportConfig
e: config\UvdConfig.kt: (12, 9): An annotation argument must be a compile-time constant

你有什么解决办法吗?

【问题讨论】:

  • 不尝试将类类型作为参数传递
  • 对不起,我不懂你,注解@Import只有类类型的参数
  • 为什么会出现错误:e: config\UvdConfig.kt: (5, 22): Unresolved reference: userpassport 文件第 5 行是什么?
  • 这是第 5 行:“import (...).config.UserpassportConfig”
  • 试着把它作为 UserpassportConfig.class

标签: java spring spring-boot gradle kotlin


【解决方案1】:

将我的分析从 cmets 转换为答案,这样问题就不会悬而未决:

我认为问题的根源在于以下错误行:e: config\UvdConfig.kt: (5, 22): Unresolved reference: userpassport。显然UserpassportConfig 所在的包不在您的构建路径上。因此,该类未正确导入,这会导致您稍后看到的错误。

【讨论】:

    猜你喜欢
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    相关资源
    最近更新 更多