【问题标题】:Name expected error when using @EnableAutoConfiguration in Spring Boot在 Spring Boot 中使用 @EnableAutoConfiguration 时命名预期错误
【发布时间】:2021-04-13 15:55:30
【问题描述】:

我遇到了与 herehere 发现的错误类似的错误。我尝试按照建议使用 @EnableAutoConfiguration 来修复错误,但 IntelliJ 给了我一个错误并说“预期名称”。我不确定究竟是什么导致了这个问题。一个可能的区别是我在 Kotlin 而不是 Java 中工作。 这是返回错误的行。

@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})

我也尝试使用第二个问题的解决方案:

@SpringBootApplication(exclude = {MongoAutoConfiguration.class})

但这也有同样的错误。

【问题讨论】:

    标签: java spring spring-boot kotlin gradle


    【解决方案1】:

    您对 Kotlin 的猜测是正确的。您正在尝试在 Kotlin 中使用 Java 语法。 在 Kotlin 中,第一个注释将如下所示:

    @EnableAutoConfiguration(exclude = [MongoAutoConfiguration::class])
    

    如有必要,请查看有关 annotations 的 Kotlin 文档以获取更多详细信息。

    【讨论】:

      猜你喜欢
      • 2014-11-17
      • 1970-01-01
      • 2015-03-25
      • 2021-12-30
      • 2018-09-21
      • 2015-04-17
      • 2020-02-25
      • 2019-06-02
      • 2016-05-02
      相关资源
      最近更新 更多