Merge branch '2.5.x'
Closes gh-28160
This commit is contained in:
@@ -490,7 +490,10 @@ include::{docs-java}/features/testing/springbootapplications/autoconfiguredsprin
|
||||
----
|
||||
|
||||
Data JPA tests may also inject a {spring-boot-test-autoconfigure-module-code}/orm/jpa/TestEntityManager.java[`TestEntityManager`] bean, which provides an alternative to the standard JPA `EntityManager` that is specifically designed for tests.
|
||||
If you want to use `TestEntityManager` outside of `@DataJpaTest` instances, you can also use the `@AutoConfigureTestEntityManager` annotation.
|
||||
|
||||
TIP: `TestEntityManager` can also be auto-configured to any of your Spring-based test class by adding `@AutoConfigureTestEntityManager`.
|
||||
When doing so, make sure that your test is running in a transaction, for instance by adding `@Transactional` on your test class or method.
|
||||
|
||||
A `JdbcTemplate` is also available if you need that.
|
||||
The following example shows the `@DataJpaTest` annotation in use:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user