当前位置: 首页 > 知识库问答 >
问题:

MySQL的Spring Boot即将关闭

楮乐邦
2023-03-14

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

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"

    <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注释类

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在这里施了太多魔法。

共有1个答案

苏昂雄
2023-03-14

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

示例

   <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>
 类似资料:
  • 问题内容: 我正在尝试编写查询以选择其生日在未来7天内的数据库用户。 我已经做了很多研究,但无法提出可行的解决方案。 生日字段存储为varchar,例如‘04 / 16/93’,有什么办法可以使用? 这是我到目前为止的内容: 我应该说得更清楚一些,我想找到生日而不是生日。所以我只是在寻找几天和几个月而不是几年。 问题答案: 要获得接下来7天内的所有生日,请将出生日期和今天之间的年份差值与出生日期相

  • 操作系统-Windows 7 Docker版本:Docker版本18.03.0-CE,版本0520E24302 springboot版本:1.5.3.发布 我从https://github.com/techprimers/docker-mysql--boot-example中获取了代码库(这是macOS中的工作示例代码) 我的应用程序.属性如下所示 Dockerfile如下所示 > 使用Docke

  • Hibernate:/*select generatedAlias0 from User为generatedAlias0*/select user0_.ID为id1_0_,user0_.CREATEDATE为createda2_0_,user0_.Email为email3_0_,user0_.PASSWORD为password4_0_,user0_.Security_LEVEL为security5

  • 问题内容: 我正在寻找有关如何使用即将到来的jsr166y(叉形联接,栅栏)和extras166y(ParallelArray等)的井井有条的信息源-从教程到专家级。 问题答案: IBM Developerworks网站上有一个很好的系列文章,但是我发现的最有用的资料是Brian Goetz的演示文稿,非常值得您花一个小时的时间。他花了前25分钟的时间谈论背景,然后介绍了新框架的一些很好的例子。

  • 我设法将我的应用程序与HSQLDB连接起来,并使其运行良好。然而,我在将它连接到MySQL时遇到了一些麻烦。 下面是我的堆栈跟踪: 应用程序运行失败 null 我的pom.xml文件: null 这里是我的application.properties文件: 如果我没有错的话,我将MySQL用户配置为与我在ubuntu中的系统用户相同,这样我就可以用“mysql-u thalysmg”启动MySQL

  • 我创建了一个docker compose文件,将MySql连接到SpringBoot应用程序。但我得到了这个错误: 我尝试在本地机器中使用docker默认ip运行Spring Boot应用程序,同时在这个docker-compose.yml文件中只运行MySql容器,结果运行得非常好。但当我尝试docker编写文件时。我知道这个错误。