关闭持久性单元“默认”的 JPA EntityManagerFactory关闭已开始...关闭已完成
我正在创建一个全新的 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该应用程序启动然后成功退出。看起来您希望它成为一个网络应用程序,为此您需要启动一个网络服务器。
您可以通过向您的应用程序添加 spring-boot-starter-web 依赖项来完成。它将向您的应用程序添加 spring-boot-starter-tomcat 。
在您的 Maven 文件中添加此内容
然后您可以摆脱 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
You can then get rid of spring-boot-starter as it is included with starter-web dependency