带有 MySQL 的 Spring Boot 立即关闭 [英] Spring Boot with MySQL is shutting down immedietly

查看:49
本文介绍了带有 MySQL 的 Spring Boot 立即关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个带有 MySQL 和 JPA 的 Spring Boot 应用程序立即关闭,我不知道原因.

My first Spring Boot application with MySQL and JPA is shutting down immediately and I do not have any clue on the reasons.

2018-08-15 16:24:42.050  INFO 10960 --- [  restartedMain] com.classpath.SampleAppApplication       : Starting SampleAppApplication on LAPTOP-MAI0FJBD with PID 10960 (C:\Users\classpath\projects\sample-app\target\classes started by classpath in C:\Users\classpath\projects\sample-app)
2018-08-15 16:24:42.065  INFO 10960 --- [  restartedMain] com.classpath.SampleAppApplication       : No active profile set, falling back to default profiles: default
2018-08-15 16:24:42.160  INFO 10960 --- [  restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@699320b1: startup date [Wed Aug 15 16:24:42 IST 2018]; root of context hierarchy
2018-08-15 16:24:43.978  INFO 10960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-08-15 16:24:44.245  INFO 10960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-08-15 16:24:44.291  INFO 10960 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-08-15 16:24:44.307  INFO 10960 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2018-08-15 16:24:44.369  INFO 10960 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
2018-08-15 16:24:44.369  INFO 10960 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-08-15 16:24:44.416  INFO 10960 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-08-15 16:24:44.526  INFO 10960 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-08-15 16:24:45.246  INFO 10960 --- [  restartedMain] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@49cf4e94'
2018-08-15 16:24:45.262  INFO 10960 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-08-15 16:24:46.058  INFO 10960 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-08-15 16:24:46.089  INFO 10960 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-15 16:24:46.089  INFO 10960 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-08-15 16:24:46.089  INFO 10960 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-08-15 16:24:46.105  INFO 10960 --- [  restartedMain] com.classpath.SampleAppApplication       : Started SampleAppApplication in 4.437 seconds (JVM running for 4.942)
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@699320b1: startup date [Wed Aug 15 16:24:42 IST 2018]; root of context hierarchy
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2018-08-15 16:24:46.121  INFO 10960 --- [       Thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Process finished with exit code 0

下面是在pom.xml 文件中添加的依赖项.http://maven.apache.org/xsd/maven-4.0.0.xsd">4.0.0com.classpath示例应用程序0.0.1-快照罐子

Below is the dependencies added in the pom.xml file. http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.classpath sample-app 0.0.1-SNAPSHOT jar

    <name>sample-app</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <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-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </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.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

我也在下面添加了 SpringBoot 注释类

I am also adding the SpringBoot annotated class below

package com.classpath;

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

    @SpringBootApplication
    public class SampleAppApplication {

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

请让我知道我哪里出错了以及如何调试这个问题.似乎 Spring 在这里发挥了太多魔力.

Please let me know where I am going wrong and how to debug this issue. Seems like Spring is doing too much magic here.

推荐答案

你的数据库依赖呢?在 pom.xml 中配置嵌入式数据库(H2、HSQL 或 Derby)或其他关系数据库,如 oracle 或 mysql 依赖项.

What about your database dependency? Configure an embedded database (H2, HSQL or Derby) or another relational database like oracle or mysql dependency inside pom.xml.

示例:

   <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>

这篇关于带有 MySQL 的 Spring Boot 立即关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆