Spring 数据 JPA + H2 嵌入式持久性:CrudRepository.save 仅在重新启动时保存到内存中不再看到更改
Spring Data JPA + H2 embedded persistence : CrudRepository.save saves only to memory on restart no longer see the changes
我有一个带有 h2 嵌入式持久性的简单 Spring Data JPA 设置。我创建了一堆实体并设置 spring.jpa.hibernate.ddl-auto=update
因为我只打算将它用作轻量级嵌入式持久性机制并且不 need/want 手动定义模式或担心模式迁移等(因为此数据不会迁移)。
现在,当我执行 CrudRepository.save
时,它可以完美运行,随后 find
调用 return 保存的实体。我也可以在 H2 控制台的休眠自动创建 tables 中看到这些。
然而,奇怪的是,当我重新启动服务时,一些更改消失了。当我稍微挖掘一下时,我发现这只发生在与封闭的 'parent' 实体处于 @OneToMany
关系中的实体。
例如,在下面的示例中,此问题仅发生在 IpInterface
实体中,当我添加另一个 IpInterface
实体并从 enclosingContainerRepository.save()
保存时。我看到一切正常,新的 IpInterface
也显示在控制台的 table 中。但是当我重新启动服务时,新的 IpInterface
实体就消失了。但是,如果我添加一个新的 EnclosingContainer
实体,该实体会在服务重新启动时正确保留。
我也尝试使用 JpaRepository
和它的 saveAndFlush
得到相同的结果。
有人知道为什么会这样吗?
public interface EnclosingContainerRepository extends CrudRepository<EnclosingContainer, String> {
...
...
}
@Entity
public class EnclosingContainer implements Serializable {
...
...
@Id
private String ipAddress;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval=true)
private SomeDTO someDTO;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private List<SomePort> somePorts;
...
...
}
@Entity
public class SomePort implements Serializable {
...
...
@Id
private String macAddress;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private List<IpInterface> ipInterfaces;
...
...
}
@Entity
public class IpInterface implements Serializable {
...
...
@Id
private String ipAddress;
...
...
}
登录服务启动(我在启动时插入了一些测试实体,它们的 SQL 日志在 post 应用程序从 ApplicationReadyEvent
事件处理程序启动后我跳过了):
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.122 [SpringContextShutdownHook] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.125 [SpringContextShutdownHook] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Shutting down ExecutorService 'applicationTaskExecutor'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.125 [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.132 [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
/usr/lib/jvm/zulu8-ca
/usr/lib/jvm/zulu8-ca/bin/java -XX:+UseContainerSupport -XX:InitialRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0 org.springframework.boot.loader.JarLauncher --port=9886
19:40:54,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:////*****/conf/logback-spring.xml]
19:40:54,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 30 seconds
19:40:54,097 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [embedded-lightweight-persistence-sample-service]
19:40:54,097 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
19:40:54,097 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
19:40:54,098 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
19:40:54,099 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
19:40:54,102 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DCM-COMMON-FILE-APPENDER]
19:40:54,108 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - setting totalSizeCap to 1 GB
19:40:54,110 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Archive files will be limited to [100 MB] each.
19:40:54,112 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Will use gz compression
19:40:54,114 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Will use the pattern /*****/logs/embedded-lightweight-persistence-sample-service.%d{yyyy-MM-dd}.%i.log for the active file
19:40:54,116 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - The date pattern is 'yyyy-MM-dd' from file name pattern '/*****/logs/embedded-lightweight-persistence-sample-service.%d{yyyy-MM-dd}.%i.log.gz'.
19:40:54,116 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - Roll-over at midnight.
19:40:54,118 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - Setting initial period to Sun Nov 22 19:40:06 GMT 2020
19:40:54,121 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
19:40:54,123 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DCM-COMMON-FILE-APPENDER] - Active log file name: /*****/logs/embedded-lightweight-persistence-sample-service.log
19:40:54,123 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DCM-COMMON-FILE-APPENDER] - File property is set to [/*****/logs/embedded-lightweight-persistence-sample-service.log]
19:40:54,124 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
19:40:54,124 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[ROOT] onto the JUL framework
19:40:54,124 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
19:40:54,124 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[ROOT]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.*****] to INFO
19:40:54,125 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[com.*****] onto the JUL framework
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.*****] to false
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.*****]
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[com.*****]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache] to WARN
19:40:54,125 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating WARN level on Logger[org.apache] onto the JUL framework
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache] to false
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.apache]
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[org.apache]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
19:40:54,125 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@2525ff7e - Registering current configuration as safe fallback point
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating DEBUG level on Logger[org.hibernate.SQL] onto the JUL framework
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating TRACE level on Logger[org.hibernate.type.descriptor.sql.BasicBinder] onto the JUL framework
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating DEBUG level on Logger[org.springframework.jdbc.core.JdbcTemplate] onto the JUL framework
19:40:54,153 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating TRACE level on Logger[org.springframework.jdbc.core.StatementCreatorUtils] onto the JUL framework
19:40:54,153 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[springfox.documentation] onto the JUL framework
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.241 [background-preinit] org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.1.5.Final
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.291 [main] com.*****.dcm.Application - Starting Application on fec4e3863bb1 with PID 1 (/BOOT-INF/lib/*****-service-base-1.0.0.jar started by root in /)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.292 [main] com.*****.dcm.Application - No active profile set, falling back to default profiles: default
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:55.506 [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFERRED mode.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:55.743 [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 220ms. Found 2 JPA repository interfaces.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.581 [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9886 (http)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.680 [main] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 2313 ms
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.841 [main] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.112 [main] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.138 [main] org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration - H2 console available at '/h2-console'. Database available at 'jdbc:h2:file:/*****/data/embeddeddb'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.470 [main] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Initializing ExecutorService 'applicationTaskExecutor'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.545 [task-1] org.hibernate.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.656 [task-1] org.hibernate.Version - HHH000412: Hibernate ORM core version 5.4.21.Final
embedded-lightweight-persistence-sample-service - [WARN ] 19:40:57.702 [main] org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration$JpaWebConfiguration - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.895 [task-1] org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
embedded-lightweight-persistence-sample-service - [WARN ] 19:40:58.039 [main] org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration - Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:58.087 [task-1] org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.736 [task-1] org.hibernate.SQL -
alter table some_port_ip_interfaces
drop constraint if exists UK_35lp2m9yn4lwhxr1wg13yeyl7
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.739 [task-1] org.hibernate.SQL -
alter table some_port_ip_interfaces
add constraint UK_35lp2m9yn4lwhxr1wg13yeyl7 unique (ip_interfaces_ip_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.741 [task-1] org.hibernate.SQL -
alter table some_port_ip_routes
drop constraint if exists UK_1xj488s5dl977k0691s4fd2qx
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.741 [task-1] org.hibernate.SQL -
alter table some_port_ip_routes
add constraint UK_1xj488s5dl977k0691s4fd2qx unique (ip_routes_ip_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.742 [task-1] org.hibernate.SQL -
alter table enclosing_container_cards
drop constraint if exists UK_7d9qcums0vny0xs332x7t4qyy
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.743 [task-1] org.hibernate.SQL -
alter table enclosing_container_cards
add constraint UK_7d9qcums0vny0xs332x7t4qyy unique (cards_serial_number)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.744 [task-1] org.hibernate.SQL -
alter table enclosing_container_frus
drop constraint if exists UK_eu4kr3fyg4mf6thowl9noyrhm
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.744 [task-1] org.hibernate.SQL -
alter table enclosing_container_frus
add constraint UK_eu4kr3fyg4mf6thowl9noyrhm unique (frus_serial_number)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.745 [task-1] org.hibernate.SQL -
alter table enclosing_container_some_ports
drop constraint if exists UK_lldpgafxjyc2gldj1unsbmx9d
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.746 [task-1] org.hibernate.SQL -
alter table enclosing_container_some_ports
add constraint UK_lldpgafxjyc2gldj1unsbmx9d unique (some_ports_mac_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.748 [task-1] org.hibernate.SQL -
alter table enclosing_container_sensors
drop constraint if exists UK_5aj4uiaxj26tn8k4gullpjqug
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.748 [task-1] org.hibernate.SQL -
alter table enclosing_container_sensors
add constraint UK_5aj4uiaxj26tn8k4gullpjqug unique (sensors_sensor_id)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.749 [task-1] org.hibernate.SQL -
alter table enclosing_container_switch_ports
drop constraint if exists UK_qwm9mj7t8vbt1qn748eakgh0n
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.750 [task-1] org.hibernate.SQL -
alter table enclosing_container_switch_ports
add constraint UK_qwm9mj7t8vbt1qn748eakgh0n unique (switch_ports_wwn)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.751 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_fcoe_ports
drop constraint if exists UK_32fnh9qvsxjk1yf2iw7cu48ek
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.751 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_fcoe_ports
add constraint UK_32fnh9qvsxjk1yf2iw7cu48ek unique (virtual_fcoe_ports_port_wwn)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.752 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_switches
drop constraint if exists UK_awii5etqk1qpq70kxu2jitt1j
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.752 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_switches
add constraint UK_awii5etqk1qpq70kxu2jitt1j unique (virtual_switches_wwn)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.791 [task-1] org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.800 [task-1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.897 [main] org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver - Exposing 13 endpoint(s) beneath base path '/actuator'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.961 [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 9886 (http) with context path '/embedded-lightweight-persistence-sample-service'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.962 [main] org.springframework.data.repository.config.DeferredRepositoryInitializationListener - Triggering deferred initialization of Spring Data repositories…
embedded-lightweight-persistence-sample-service - [INFO ] 19:41:00.445 [main] org.springframework.data.repository.config.DeferredRepositoryInitializationListener - Spring Data repositories initialized!
embedded-lightweight-persistence-sample-service - [INFO ] 19:41:00.461 [main] com.*****.dcm.Application - Started Application in 6.711 seconds (JVM running for 7.5)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:41:00.551 [main] org.hibernate.SQL -
....
....
更新(2020 年 11 月 22 日):
伙计们,打扰了,我想这是我在更新 parent 实体时所做的愚蠢事情的原因,该实体的 ID 与我在应用程序启动时测试编辑操作时使用的 ID 相同(错过了删除 post 我的初始验证)导致更改的外观在重新启动后不会持续存在。当我删除它时,它就像 breeze.
感谢每一位看过的人。特别感谢@Shawrup 关于检查启动时发生的事情的有用说明,这帮助我意识到我正在做的错误。
只想回答并关闭这个。
事实证明,问题是因为我的测试代码更新了我在启动时测试编辑操作时使用的同一实体,这使得更改看起来不会在重新启动后持续存在,而实际上它们确实存在。
感谢@Shawrup 通过查看启动日志帮助我发现问题。
谢谢
我有一个带有 h2 嵌入式持久性的简单 Spring Data JPA 设置。我创建了一堆实体并设置 spring.jpa.hibernate.ddl-auto=update
因为我只打算将它用作轻量级嵌入式持久性机制并且不 need/want 手动定义模式或担心模式迁移等(因为此数据不会迁移)。
现在,当我执行 CrudRepository.save
时,它可以完美运行,随后 find
调用 return 保存的实体。我也可以在 H2 控制台的休眠自动创建 tables 中看到这些。
然而,奇怪的是,当我重新启动服务时,一些更改消失了。当我稍微挖掘一下时,我发现这只发生在与封闭的 'parent' 实体处于 @OneToMany
关系中的实体。
例如,在下面的示例中,此问题仅发生在 IpInterface
实体中,当我添加另一个 IpInterface
实体并从 enclosingContainerRepository.save()
保存时。我看到一切正常,新的 IpInterface
也显示在控制台的 table 中。但是当我重新启动服务时,新的 IpInterface
实体就消失了。但是,如果我添加一个新的 EnclosingContainer
实体,该实体会在服务重新启动时正确保留。
我也尝试使用 JpaRepository
和它的 saveAndFlush
得到相同的结果。
有人知道为什么会这样吗?
public interface EnclosingContainerRepository extends CrudRepository<EnclosingContainer, String> {
...
...
}
@Entity
public class EnclosingContainer implements Serializable {
...
...
@Id
private String ipAddress;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval=true)
private SomeDTO someDTO;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private List<SomePort> somePorts;
...
...
}
@Entity
public class SomePort implements Serializable {
...
...
@Id
private String macAddress;
@OneToMany(cascade=CascadeType.ALL, orphanRemoval=true)
private List<IpInterface> ipInterfaces;
...
...
}
@Entity
public class IpInterface implements Serializable {
...
...
@Id
private String ipAddress;
...
...
}
登录服务启动(我在启动时插入了一些测试实体,它们的 SQL 日志在 post 应用程序从 ApplicationReadyEvent
事件处理程序启动后我跳过了):
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.122 [SpringContextShutdownHook] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.125 [SpringContextShutdownHook] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Shutting down ExecutorService 'applicationTaskExecutor'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.125 [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:06.132 [SpringContextShutdownHook] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
/usr/lib/jvm/zulu8-ca
/usr/lib/jvm/zulu8-ca/bin/java -XX:+UseContainerSupport -XX:InitialRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0 org.springframework.boot.loader.JarLauncher --port=9886
19:40:54,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:////*****/conf/logback-spring.xml]
19:40:54,095 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 30 seconds
19:40:54,097 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [embedded-lightweight-persistence-sample-service]
19:40:54,097 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
19:40:54,097 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
19:40:54,098 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
19:40:54,099 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
19:40:54,102 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DCM-COMMON-FILE-APPENDER]
19:40:54,108 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - setting totalSizeCap to 1 GB
19:40:54,110 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Archive files will be limited to [100 MB] each.
19:40:54,112 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Will use gz compression
19:40:54,114 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1610702581 - Will use the pattern /*****/logs/embedded-lightweight-persistence-sample-service.%d{yyyy-MM-dd}.%i.log for the active file
19:40:54,116 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - The date pattern is 'yyyy-MM-dd' from file name pattern '/*****/logs/embedded-lightweight-persistence-sample-service.%d{yyyy-MM-dd}.%i.log.gz'.
19:40:54,116 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - Roll-over at midnight.
19:40:54,118 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1356d4d4 - Setting initial period to Sun Nov 22 19:40:06 GMT 2020
19:40:54,121 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
19:40:54,123 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DCM-COMMON-FILE-APPENDER] - Active log file name: /*****/logs/embedded-lightweight-persistence-sample-service.log
19:40:54,123 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[DCM-COMMON-FILE-APPENDER] - File property is set to [/*****/logs/embedded-lightweight-persistence-sample-service.log]
19:40:54,124 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
19:40:54,124 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[ROOT] onto the JUL framework
19:40:54,124 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
19:40:54,124 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[ROOT]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.*****] to INFO
19:40:54,125 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[com.*****] onto the JUL framework
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.*****] to false
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.*****]
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[com.*****]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache] to WARN
19:40:54,125 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating WARN level on Logger[org.apache] onto the JUL framework
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache] to false
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.apache]
19:40:54,125 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DCM-COMMON-FILE-APPENDER] to Logger[org.apache]
19:40:54,125 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
19:40:54,125 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@2525ff7e - Registering current configuration as safe fallback point
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating DEBUG level on Logger[org.hibernate.SQL] onto the JUL framework
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating TRACE level on Logger[org.hibernate.type.descriptor.sql.BasicBinder] onto the JUL framework
19:40:54,152 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating DEBUG level on Logger[org.springframework.jdbc.core.JdbcTemplate] onto the JUL framework
19:40:54,153 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating TRACE level on Logger[org.springframework.jdbc.core.StatementCreatorUtils] onto the JUL framework
19:40:54,153 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@6c779568 - Propagating INFO level on Logger[springfox.documentation] onto the JUL framework
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.241 [background-preinit] org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.1.5.Final
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.291 [main] com.*****.dcm.Application - Starting Application on fec4e3863bb1 with PID 1 (/BOOT-INF/lib/*****-service-base-1.0.0.jar started by root in /)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:54.292 [main] com.*****.dcm.Application - No active profile set, falling back to default profiles: default
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:55.506 [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFERRED mode.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:55.743 [main] org.springframework.data.repository.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 220ms. Found 2 JPA repository interfaces.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.581 [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 9886 (http)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.680 [main] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 2313 ms
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:56.841 [main] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.112 [main] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.138 [main] org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration - H2 console available at '/h2-console'. Database available at 'jdbc:h2:file:/*****/data/embeddeddb'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.470 [main] org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor - Initializing ExecutorService 'applicationTaskExecutor'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.545 [task-1] org.hibernate.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.656 [task-1] org.hibernate.Version - HHH000412: Hibernate ORM core version 5.4.21.Final
embedded-lightweight-persistence-sample-service - [WARN ] 19:40:57.702 [main] org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration$JpaWebConfiguration - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:57.895 [task-1] org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
embedded-lightweight-persistence-sample-service - [WARN ] 19:40:58.039 [main] org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration - Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:58.087 [task-1] org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.736 [task-1] org.hibernate.SQL -
alter table some_port_ip_interfaces
drop constraint if exists UK_35lp2m9yn4lwhxr1wg13yeyl7
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.739 [task-1] org.hibernate.SQL -
alter table some_port_ip_interfaces
add constraint UK_35lp2m9yn4lwhxr1wg13yeyl7 unique (ip_interfaces_ip_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.741 [task-1] org.hibernate.SQL -
alter table some_port_ip_routes
drop constraint if exists UK_1xj488s5dl977k0691s4fd2qx
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.741 [task-1] org.hibernate.SQL -
alter table some_port_ip_routes
add constraint UK_1xj488s5dl977k0691s4fd2qx unique (ip_routes_ip_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.742 [task-1] org.hibernate.SQL -
alter table enclosing_container_cards
drop constraint if exists UK_7d9qcums0vny0xs332x7t4qyy
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.743 [task-1] org.hibernate.SQL -
alter table enclosing_container_cards
add constraint UK_7d9qcums0vny0xs332x7t4qyy unique (cards_serial_number)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.744 [task-1] org.hibernate.SQL -
alter table enclosing_container_frus
drop constraint if exists UK_eu4kr3fyg4mf6thowl9noyrhm
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.744 [task-1] org.hibernate.SQL -
alter table enclosing_container_frus
add constraint UK_eu4kr3fyg4mf6thowl9noyrhm unique (frus_serial_number)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.745 [task-1] org.hibernate.SQL -
alter table enclosing_container_some_ports
drop constraint if exists UK_lldpgafxjyc2gldj1unsbmx9d
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.746 [task-1] org.hibernate.SQL -
alter table enclosing_container_some_ports
add constraint UK_lldpgafxjyc2gldj1unsbmx9d unique (some_ports_mac_address)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.748 [task-1] org.hibernate.SQL -
alter table enclosing_container_sensors
drop constraint if exists UK_5aj4uiaxj26tn8k4gullpjqug
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.748 [task-1] org.hibernate.SQL -
alter table enclosing_container_sensors
add constraint UK_5aj4uiaxj26tn8k4gullpjqug unique (sensors_sensor_id)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.749 [task-1] org.hibernate.SQL -
alter table enclosing_container_switch_ports
drop constraint if exists UK_qwm9mj7t8vbt1qn748eakgh0n
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.750 [task-1] org.hibernate.SQL -
alter table enclosing_container_switch_ports
add constraint UK_qwm9mj7t8vbt1qn748eakgh0n unique (switch_ports_wwn)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.751 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_fcoe_ports
drop constraint if exists UK_32fnh9qvsxjk1yf2iw7cu48ek
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.751 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_fcoe_ports
add constraint UK_32fnh9qvsxjk1yf2iw7cu48ek unique (virtual_fcoe_ports_port_wwn)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.752 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_switches
drop constraint if exists UK_awii5etqk1qpq70kxu2jitt1j
embedded-lightweight-persistence-sample-service - [DEBUG] 19:40:59.752 [task-1] org.hibernate.SQL -
alter table enclosing_container_virtual_switches
add constraint UK_awii5etqk1qpq70kxu2jitt1j unique (virtual_switches_wwn)
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.791 [task-1] org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.800 [task-1] org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.897 [main] org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver - Exposing 13 endpoint(s) beneath base path '/actuator'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.961 [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 9886 (http) with context path '/embedded-lightweight-persistence-sample-service'
embedded-lightweight-persistence-sample-service - [INFO ] 19:40:59.962 [main] org.springframework.data.repository.config.DeferredRepositoryInitializationListener - Triggering deferred initialization of Spring Data repositories…
embedded-lightweight-persistence-sample-service - [INFO ] 19:41:00.445 [main] org.springframework.data.repository.config.DeferredRepositoryInitializationListener - Spring Data repositories initialized!
embedded-lightweight-persistence-sample-service - [INFO ] 19:41:00.461 [main] com.*****.dcm.Application - Started Application in 6.711 seconds (JVM running for 7.5)
embedded-lightweight-persistence-sample-service - [DEBUG] 19:41:00.551 [main] org.hibernate.SQL -
....
....
更新(2020 年 11 月 22 日): 伙计们,打扰了,我想这是我在更新 parent 实体时所做的愚蠢事情的原因,该实体的 ID 与我在应用程序启动时测试编辑操作时使用的 ID 相同(错过了删除 post 我的初始验证)导致更改的外观在重新启动后不会持续存在。当我删除它时,它就像 breeze.
感谢每一位看过的人。特别感谢@Shawrup 关于检查启动时发生的事情的有用说明,这帮助我意识到我正在做的错误。
只想回答并关闭这个。
事实证明,问题是因为我的测试代码更新了我在启动时测试编辑操作时使用的同一实体,这使得更改看起来不会在重新启动后持续存在,而实际上它们确实存在。
感谢@Shawrup 通过查看启动日志帮助我发现问题。
谢谢