java - 将 Spring boot 1.5 迁移到 2.x 无法启动应用程序

标签 java spring spring-boot

我是 Spring boot 新手,正在尝试将现有应用程序从 1.5 迁移到 2.0。 我浏览了迁移指南,发现将 preoperties-migrator 作为依赖项包含在我的父 pom 中将指出为了迁移而需要进行的更改。因此,我在我的 pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-properties-migrator</artifactId>
    <version>2.0.4.RELEASE</version>
</dependency>

添加以下依赖项后,应用程序启动失败并出现以下错误。

"message":"Application startup failed","logger_name":"org.springframework.boot.SpringApplication","thread_name":"main","level":"ERROR","level_value":40000,"stack_trace":"java.lang.NoClassDefFoundError: org/springframework/boot/env/OriginTrackedMapPropertySource\n\tat org.springframework.boot.context.properties.migrator.PropertiesMigrationListener.onApplicationPreparedEvent(PropertiesMigrationListener.java:67)\n\tat org.springframework.boot.context.properties.migrator.PropertiesMigrationListener.onApplicationEvent(PropertiesMigrationListener.java:57)\n\tat org.springframework.boot.context.properties.migrator.PropertiesMigrationListener.onApplicationEvent(PropertiesMigrationListener.java:44)\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)\n\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)\n\tat org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:91)\n\tat org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)\n\tat org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:356)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:301)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)\n\tat com.move.aws.eai.inventory.common.app.BaseApplication.run(BaseApplication.java:140)\n\tat com.move.aws.eai.inventory.bulk.Application.main(Application.java:10)\nCaused by: java.lang.ClassNotFoundException: org.springframework.boot.env.OriginTrackedMapPropertySource\n\tat java.net.URLClassLoader.findClass(URLClassLoader.java:381)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:424)\n\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:357)\n\t... 15 common frames omitted\n"}

谁能指出问题所在吗?

pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.move.aws.eai.inventory</groupId>
    <artifactId>aurora</artifactId>
    <version>1.0.20-SNAPSHOT</version>
  </parent>
  <groupId>com.move.aws.eai.inventory.aurora</groupId>
  <artifactId>bulk</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <name>Inventory and Waitlist Bulk API</name>
  <dependencies>
    <dependency>
      <groupId>com.move.aws.eai.inventory.aurora</groupId>
      <artifactId>common</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-sts</artifactId>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-s3</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-dbcp2</artifactId>
    </dependency>
    <!-- Features toggling -->
    <dependency>
      <groupId>org.togglz</groupId>
      <artifactId>togglz-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.togglz</groupId>
      <artifactId>togglz-console</artifactId>
    </dependency>
    <!-- Testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.powermock</groupId>
      <artifactId>powermock-module-junit4</artifactId>
    </dependency>
    <dependency>
      <groupId>org.powermock</groupId>
      <artifactId>powermock-api-mockito2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.github.stefanbirkner</groupId>
      <artifactId>system-rules</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter-test</artifactId>
    </dependency>
  </dependencies>
  <build>
    <finalName>inventory-bulk</finalName>
    <plugins>
      <plugin>
        <!-- Package as an executable jar -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>true</executable>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>EnterpriseSystems-inventory-maven</name>
      <url>https://artifactory.moveaws.com/artifactory/EnterpriseSystems-inventory-maven</url>
    </repository>
    <repository>
      <snapshots />
      <id>snapshots</id>
      <name>EnterpriseSystems-inventory-maven</name>
      <url>https://artifactory.moveaws.com/artifactory/EnterpriseSystems-inventory-maven</url>
    </repository>
  </repositories>
</project>

最佳答案

这是一个愚蠢的错误。

我更改了父 pom.xml 以使用最新的 Spring boot 版本。

关于java - 将 Spring boot 1.5 迁移到 2.x 无法启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52037595/

相关文章:

java - 如何通过包含 namespace 信息来创建 XML 元素?

java - Eclipse 在调试时显示 Java 字节数组的红色值

spring - 如何在代理后面配置 Spring HATEOAS?

java - Hystrix 仪表板不工作

java - 如何在 Heroku 上托管 spring-boot 微服务 dockerized(docker compose) 应用程序

java - Android 要求不要在主线程上查询,但异步查询正在延迟

java - 防止程序员获取类实例的锁

eclipse - 需要做一个简单的 spring 3 示例工作

java - Spock测试方法中无法加载Spring上下文

spring-boot - 用于执行gradle bootBuildImage命令的Docker镜像