关闭应用程序后删除Spring JPA数据 [英] Spring JPA data removed after shutdown of application
问题描述
我有一个基于Spring引导的应用程序,它使用HSQL数据库上的JPA存储库.
i have an application thats build on Spring boot, using JPA repositories on HSQL database.
问题是,在应用程序运行时,我创建了一个实体,并将其正确持久存储到数据库中(可以在数据库管理器中看到).但是从eclipse关闭应用程序后,所有数据都将被删除;
Problem is that while application is running, I create an entity,and it's persisted correctly to database(can be seen in database manager). But after application shutdown from eclipse, all data is removed;
保存是这样的
@Service
public class NotificationService {
@Autowired
private NotificationRepository notificationRepository;
public void notifyRefreshArticles(){
Notification notification = new Notification();
notification.setCreatedAt(LocalDateTime.now());
notification.setNotificationSeverity(NotificationSeverity.NORMAL);
notification.setNotificationType(NotificationType.REFRESH_ARTICLES);
notificationRepository.save(notification);
}
}
我非常确定它的配置问题,但是对于Spring Boot,基本上我只有的配置是该配置文件.
I pretty sure its configuration issue,but with spring boot basically only configuration that i have is this configuration file.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:hsql://localhost/rr_app_database
spring.datasource.username=XXXXXX
spring.datasource.password=XXXXXX
spring.datasource.show-sql=true
推荐答案
配置属性中是否有hbm2ddl文本.应该将其设置为update
或none
,显然您可能具有create-drop
.
Do you have hbm2ddl text somewhere in your configuration properties. It should be set to update
or none
, apparently you might have create-drop
.
这篇关于关闭应用程序后删除Spring JPA数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!