首页 > 解决方案 > 无法启动 Spring Boot 2.0.2 应用程序

问题描述

我们开始使用 spring boot 2.0.2 应用程序,当我们尝试运行 main 方法时,它会启动但会立即关闭。在 pom.xml 中,当我将父 Spring Boot 版本更改为 2.0.1 时,它运行正常。我什至尝试从https://start.spring.io/下载 spring boot 2.0.2 应用程序,但问题仍然存在。我正在使用 java 1.8,也尝试过使用 java 1.9。2.0.2 是否需要进行任何特定配置才能正常工作?

pom.xml

<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>
    <groupId>com.kalavakuri.springbootpractice</groupId>
    <artifactId>springbootpractice</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <packaging>war</packaging>

</project>

ApplicationStarter.java - 这是主类。

package com.kalavakuri.springbootpractice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ApplicationStarter {

    public static void main(String[] args) {
        SpringApplication.run(ApplicationStarter.class, args);
    }
}

以下是日志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.2.RELEASE)

2018-06-09 13:39:25.705  INFO 14016 --- [           main] c.k.s.ApplicationStarter                 : Starting ApplicationStarter on DESKTOP-03U51UO with PID 14016 (C:\Personal\oxygen-workspace\springbootpractice\target\classes started by Ramachandrappa K in C:\Personal\oxygen-workspace\springbootpractice)
2018-06-09 13:39:25.705  INFO 14016 --- [           main] c.k.s.ApplicationStarter                 : No active profile set, falling back to default profiles: default
2018-06-09 13:39:25.799  INFO 14016 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7f77e91b: startup date [Sat Jun 09 13:39:25 IST 2018]; root of context hierarchy
2018-06-09 13:39:27.351  INFO 14016 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-06-09 13:39:27.384  INFO 14016 --- [           main] c.k.s.ApplicationStarter                 : Started ApplicationStarter in 2.183 seconds (JVM running for 2.893)
2018-06-09 13:39:27.384  INFO 14016 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7f77e91b: startup date [Sat Jun 09 13:39:25 IST 2018]; root of context hierarchy
2018-06-09 13:39:27.384  INFO 14016 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

标签: springspring-boot

解决方案


推荐阅读