Spring Boot with MySQL is shutting down immedietly

给你一囗甜甜゛ 提交于 2020-01-25 09:33:44

问题


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

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>

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);
        }
    }

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


回答1:


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.

Example:

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


来源:https://stackoverflow.com/questions/51857478/spring-boot-with-mysql-is-shutting-down-immedietly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!