java Sping Boot 应用程序立即关闭

ojsjcaue  于 2023-06-04  发布在  Java
关注(0)|答案(2)|浏览(261)

为什么spring Boot 应用程序会自动关闭。
控制台中显示的消息。

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

2020-06-03 23:25:43.794  INFO 26936 --- [           main] c.e.d.DatajpaexampleApplication          : Starting DatajpaexampleApplication on HMECL002810A with PID 26936 (C:\Users\Ravishankar.kumar\Desktop\MyWorkspace\SpringDataJpa\datajpaexample\target\classes started by Ravishankar.kumar in C:\Users\Ravishankar.kumar\Desktop\MyWorkspace\SpringDataJpa\datajpaexample)
2020-06-03 23:25:43.797  INFO 26936 --- [           main] c.e.d.DatajpaexampleApplication          : No active profile set, falling back to default profiles: default
2020-06-03 23:25:44.467  INFO 26936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-06-03 23:25:44.515  INFO 26936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 27ms. Found 0 JPA repository interfaces.
2020-06-03 23:25:45.148  INFO 26936 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-03 23:25:45.161  INFO 26936 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-06-03 23:25:46.299  INFO 26936 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-06-03 23:25:46.358  INFO 26936 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-06-03 23:25:46.495  INFO 26936 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.15.Final
2020-06-03 23:25:46.571  INFO 26936 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-06-03 23:25:46.571  INFO 26936 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-06-03 23:25:46.583  INFO 26936 --- [           main] c.e.d.DatajpaexampleApplication          : Started DatajpaexampleApplication in 3.261 seconds (JVM running for 3.692)
2020-06-03 23:25:46.787  INFO 26936 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-06-03 23:25:47.041  INFO 26936 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-06-03 23:25:47.351  INFO 26936 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-06-03 23:25:47.360  INFO 26936 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-06-03 23:26:47.396  INFO 26936 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-03 23:26:47.410  INFO 26936 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2020-06-03 23:26:47.411  INFO 26936 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2020-06-03 23:26:47.419  INFO 26936 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>datajpaexample</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>datajpaexample</name>
    <description>Demo project for Spring Boot</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

</project>

application.properties

spring.datasource.url = jdbc:mysql://localhost:3306/test_datajpa
spring.datasource.username = root
spring.datasource.password = root

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

server.port = 8085

DatajpaexampleApplication.class

package com.example.datajpaexample;

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

@SpringBootApplication
public class DatajpaexampleApplication {

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

}

我试过很多种方法,但同样的问题。
1.C:\Users\classpath.m2\repository\org\apache\tomcat\embedded\tomcat-embedded-core\8.5.32
1.添加了这些额外的依赖项

<dependency>
     <groupId>org.hsqldb</groupId>
     <artifactId>hsqldb</artifactId>
     <scope>runtime</scope>
  </dependency>
  <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-tomcat</artifactId>
     <scope>provided</scope>
  </dependency>

有人能帮我吗。

0pizxfdo

0pizxfdo1#

我将父版本 2.3.0.RELEASE 更改为 2.2.1.RELEASE。现在工作正常。

yeotifhr

yeotifhr2#

尝试删除artifactId spring-boot-starter-tomcat的代码<scope>provided</scope>并重新运行应用程序

相关问题