79657743

Date: 2025-06-08 10:30:25
Score: 1.5
Natty:
Report link

I have fixed this problem and the solution is really simple if someone else is stuck like I was- I replaced the annotations I was using in my RepositoryTests (@SpringBootTest, @ExtendsWith, @DirtiesContext) with @DataJpaTest.

So basically, with @SpringBootTest I was previously loading the full application info and all the beans which included my Postgres database I was using for the main application, this was messing with my in-memory h2 database that I was using for tests.
But using @DataJpaTest provided all the same functionality whilst only loading the necessary beans and only using the h2 database.

Reasons:
  • Whitelisted phrase (-1): solution is
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @ExtendsWith
  • User mentioned (0): @DirtiesContext
  • User mentioned (0): @DataJpaTest
  • User mentioned (0): @SpringBootTest
  • User mentioned (0): @DataJpaTest
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Vansh Bansal