3

I need to update the config spring.jpa.hibernate.ddl-auto for one of my test classes. It should remain as update for all classes except one.

How do I achieve this at run time when session is being managed by 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.

Rajeev Ranjan
  • 3,588
  • 6
  • 28
  • 52
  • 1
    What about `@TestPropertySource`? You can use it like this on your test class: `@TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto = none")` – Dmitry Senkovich Oct 21 '17 at 21:53
  • Well. Thank u so much @DmitrySenkovich . It works for me. Just setting thid annotation at the top of the class that need to have exclusive behaviour. Here's a related link https://stackoverflow.com/questions/32633638/testpropertsource-and-propertysource-dont-work-for-junit . – Rajeev Ranjan Oct 22 '17 at 06:08
  • oh, that's nice) – Dmitry Senkovich Oct 22 '17 at 07:03

1 Answers1

6

Well, simply adding @TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto = none") on a test class should work. That's all:)

Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74