0

我尝试使用 spring 初始化程序创建 Spring Boot 应用程序。我刚刚使用依赖项创建了新应用程序

<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-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>

但是当我尝试启动应用程序时它只是关闭了。我创建了控制器并遵循所有解决方案,例如:更改端口或从 .m2 文件夹中删除 tomcat,但没有任何效果。这些是我的日志

2021-04-30 02:50:10,845 INFO  [main] org.hibernate.dialect.Dialect: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-04-30 02:50:12,067 INFO  [main] org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-04-30 02:50:12,087 INFO  [main] org.springframework.orm.jpa.AbstractEntityManagerFactoryBean: Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-04-30 02:50:12,914 INFO  [main] org.springframework.boot.StartupInfoLogger: Started WebApplication in 7.549 seconds (JVM running for 8.848)
2021-04-30 02:50:13,025 INFO  [SpringContextShutdownHook] org.springframework.orm.jpa.AbstractEntityManagerFactoryBean: Closing JPA EntityManagerFactory for persistence unit 'default'
2021-04-30 02:50:13,027 INFO  [SpringContextShutdownHook] org.hibernate.tool.schema.internal.SchemaDropperImpl$DelayedDropActionImpl: HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2021-04-30 02:50:13,037 INFO  [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown initiated...
2021-04-30 02:50:13,045 INFO  [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Shutdown completed.

Process finished with exit code 0

如果有人知道出了什么问题。我正在使用 Spring Boot 2.4.5 版本。

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

1 回答 1

0

似乎tomcat嵌入式jar不包含在依赖项/jar中。由于已经定义了“spring-boot-starter-web”依赖项,因此它应该是可传递的。但不知何故,它被排除在外。

尝试执行“mvn dependency:tree”并检查tomcat依赖项是否存在以及是否在“compile”范围内

于 2021-04-29T22:42:30.490 回答