spring-bootspring-data-jdbc

DataJdbcTest Configuration


I asked and answered a previous question here that has now come back to bite me. Unfortunately, this only works with @SpringBootTest which loads the entire application context and causes an error when I use the following configuration:

@ExtendWith(SpringExtension.class)
@DataJdbcTest
@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.NONE)

Spring throws an error because it assumes I am using the default naming strategy when naming my columns. I also using postgres instead of H2 Is their any way for me to get spring to load that single custom configuration or do I have to revert back to speed up my tests? Thank you.


Solution

  • The documentation of DataJdbcTest says

    Using this annotation will disable full auto-configuration, scan for AbstractJdbcConfiguration subclasses, and apply only configuration relevant to Data JDBC tests.

    So having a AbstractJdbcConfiguration which applies the NamingStrategy should be sufficient.