Spring Boot 2.1 exposes a property spring.data.jpa.repositories.bootstrap-mode that can be set to default (default) deferred or lazy. I suggest do change the default value for property to be changed in the following scenarios:
- Change the general default to
deferred – it parallelizes the bootstrap of the EntityManagerFactory and delays repository initialization to the end of the ApplicationContext initialization. I.e. there are performance benefits to the startup but the app is the same state as with the current default once it has been started.
- Default to
lazy for @SpringBootTest, @DataJpaTest – this leaves all but repositories injected into the tests initialized which gives a bit of a performance boost in both scenarios.
Spring Boot 2.1 exposes a property
spring.data.jpa.repositories.bootstrap-modethat can be set todefault(default)deferredorlazy. I suggest do change the default value for property to be changed in the following scenarios:deferred– it parallelizes the bootstrap of theEntityManagerFactoryand delays repository initialization to the end of theApplicationContextinitialization. I.e. there are performance benefits to the startup but the app is the same state as with the current default once it has been started.lazyfor@SpringBootTest,@DataJpaTest– this leaves all but repositories injected into the tests initialized which gives a bit of a performance boost in both scenarios.