简体   繁体   English

在运行时Hibernate / JPA更新Springboot属性

[英]Update Springboot properties at runtime Hibernate/JPA

I need to update the config spring.jpa.hibernate.ddl-auto for one of my test classes. 我需要为我的一个测试类更新config spring.jpa.hibernate.ddl-auto It should remain as update for all classes except one. 它应该保留为除一个类之外的所有类的update

How do I achieve this at run time when session is being managed by Springboot? 如何在Springboot管理会话的运行时实现此目的? Or is there some other way out? 或者还有其他方法吗? I had the option to create a session afresh and use it as here but session is not managed manually. 我可以选择重新创建会话并在此处使用它,但不会手动管理会话。

Well, simply adding @TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto = none") on a test class should work. 好吧,只需在测试类上添加@TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto = none") That's all:) 就这样:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM