关闭持久性单元“默认”的 JPA EntityManagerFactory关闭已开始...关闭已完成

发布于 2025-01-09 23:42:27 字数 1661 浏览 1 评论 0原文

我正在创建一个全新的 Spring Boot 应用程序, 我有以下依赖项。

<artifactId>spring-boot-starter</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<artifactId>spring-kafka</artifactId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>lombok</artifactId>
<artifactId>mysql-connector-java</artifactId>

应用程序启动,但关闭并显示以下警告日志。

2022-02-25 23:58:10.225  INFO 72504 --- [           main] c.d.c.l.LibrarydemoApplication           : Started LibrarydemoApplication in 1.512 seconds (JVM running for 2.016)
2022-02-25 23:58:10.230  INFO 72504 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-02-25 23:58:10.232  INFO 72504 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2022-02-25 23:58:10.236  INFO 72504 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Mysql连接良好。下面是应用程序 props 的配置。

spring.datasource.url=jdbc:mysql://localhost:3306/repo
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update

请告知如何解决这个问题。

输入图片此处描述

I am creating a brand new spring boot application,
I have the below dependencies.

<artifactId>spring-boot-starter</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<artifactId>spring-kafka</artifactId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>lombok</artifactId>
<artifactId>mysql-connector-java</artifactId>

The application starts but it shutsdown with below warning logs.

2022-02-25 23:58:10.225  INFO 72504 --- [           main] c.d.c.l.LibrarydemoApplication           : Started LibrarydemoApplication in 1.512 seconds (JVM running for 2.016)
2022-02-25 23:58:10.230  INFO 72504 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-02-25 23:58:10.232  INFO 72504 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2022-02-25 23:58:10.236  INFO 72504 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Mysql connectivity is good. below is the config of application props.

spring.datasource.url=jdbc:mysql://localhost:3306/repo
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update

Please advise how resolve this issue.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿挽旧人 2025-01-16 23:42:27

该应用程序启动然后成功退出。看起来您希望它成为一个网络应用程序,为此您需要启动一个网络服务器。
您可以通过向您的应用程序添加 spring-boot-starter-web 依赖项来完成。它将向您的应用程序添加 spring-boot-starter-tomcat 。

在您的 Maven 文件中添加此内容

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

然后您可以摆脱 spring-boot-starter,因为它包含在 starter-web 依赖项中

The app started and then exited successfully. Looks like you want it to be a webapp and for that you need to start a webserver.
You can do by adding spring-boot-starter-web dependency to your app.It will add spring-boot-starter-tomcat to your app.

In your maven file add this

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

You can then get rid of spring-boot-starter as it is included with starter-web dependency

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文