spring启动应用程序运行后自动关闭

tf7tbtn2  于 2021-07-12  发布在  Java
关注(0)|答案(2)|浏览(689)

每当我尝试运行我的应用程序时,我都会得到这个日志。我尝试在application.properties上添加更多参数(如 spring.jpa.hibernate.ddl-auto=update )但这只会破坏应用程序并显示更多错误。我找不到办法把它修好。

2021-04-23 11:21:00.351  INFO 6292 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-04-23 11:21:01.019  INFO 6292 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-04-23 11:21:01.074  INFO 6292 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-04-23 11:21:01.148  INFO 6292 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.28.Final
2021-04-23 11:21:01.562  INFO 6292 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-04-23 11:21:01.747  INFO 6292 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2021-04-23 11:21:02.552  INFO 6292 --- [  restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-04-23 11:21:02.562  INFO 6292 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-04-23 11:21:02.735  INFO 6292 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-04-23 11:21:02.752  INFO 6292 --- [  restartedMain] com.accenture.ws.Application             : Started Application in 4.503 seconds (JVM running for 5.792)
2021-04-23 11:21:02.763  INFO 6292 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-04-23 11:21:02.767  INFO 6292 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-04-23 11:21:02.784  INFO 6292 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

这是我的pom.xml–在pom.xml上是否有任何配置错误的内容?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.stackoverflow.net</groupId>
    <artifactId>application-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>application-test.stackoverflow</name>
    <description>application-test API</description>
    <properties>
        <java.version>11</java.version>
        <testcontainers.version>1.15.3</testcontainers.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-jdbc</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>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers-bom</artifactId>
                <version>${testcontainers.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

这是我的应用程序。属性-

spring.datasource.url=jdbc:mysql://localhost:3306/?user=root/devops_db?
useSSL=false&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC

spring.datasource.username=username
spring.datasource.password=password

server.error.include-stacktrace=never
spring.jackson.serialization.indent-output=true

server.port=8090
mmvthczy

mmvthczy1#

spring引导应用程序不会自动关闭,但hikari连接会自动关闭。我发现数据源url有一个问题:我注意到 ...devops_db? 以及 useSSl=false... 不应该存在的部分。
复制并粘贴此内容(即,将属性文件的前两行替换为下一行):

spring.datasource.url=jdbc:mysql://localhost:3306/?user=root/devops_db?useSSL=false&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
7jmck4yq

7jmck4yq2#

你能为我设置日志记录级别吗 org.springframework 作为 debug 随着 spring.jpa.hibernate.ddl-auto=none 分享结果。你也可以共享数据源配置吗

相关问题