【问题标题】:Spring Boot Properties MigratorSpring Boot 属性迁移器
【发布时间】:2019-11-25 12:55:47
【问题描述】:

我正在尝试运行具有依赖关系的应用程序(spring boot v1.5.9.0):

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-properties-migrator</artifactId>
  <scope>runtime</scope>
</dependency>

并收到此错误:

org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/source/ConfigurationPropertySources

这个错误显然以前没有发生过。如何使迁移器工作?

在运行迁移器之前,我是否必须将 spring-boot 版本更改为 2x? 如果是这样,我并没有真正了解迁移器的使用情况。 因为它的范围是运行时——我必须让应用程序在包含它之前运行——这意味着我必须在没有迁移者建议的情况下解决所有错误?以后我用它做什么?

【问题讨论】:

标签: java spring spring-boot


【解决方案1】:

您已声明您正在运行 spring boot v1.5.9.0

使用 spring boot 1.5.x 运行属性迁移器没有意义。其主要目的是“协助”在将 spring boot 1.x 迁移到 spring boot 2.x 期间发生更改的属性迁移

至于报错,这个具体的类是从spring boot 2.0开始才有的。见the sourcefile中的评论@since

【讨论】:

  • 我认为它可以帮助我在更改版本之前更改注释、导入等。所以这意味着我必须尝试使用​​ 2.x 版本运行应用程序,处理所有错误,然后我才能看到迁移器输出?这对我来说真的没有意义。谢谢你的回答:)
  • 没有。您使用新版本但使用旧属性运行它。它有助于迁移,因为许多属性在 spring boot 1.x 和 2.x 之间发生了变化。它是一个辅助工具。
【解决方案2】:

在您的项目中,application.propertiesapplication.yml 是否存在? Spring bootauto-configuration。我认为这些属性将是预期的..还要检查 annotations 中使用的 Spring boot 主类..分享 Spring boot main class 以及..将检查

【讨论】:

    猜你喜欢
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 2018-08-16
    • 2020-12-07
    • 2023-03-20
    • 2019-01-07
    • 2020-11-18
    相关资源
    最近更新 更多