I am trying to write a SOAP service using Spring, however I receive a Dependency Injection issue. I\'m having problems using @Autowired
through the Service like
In my case, the application context is not loaded because I add @DataJpaTest
annotation. When I change it to @SpringBootTest
it works.
@DataJpaTest
only loads the JPA part of a Spring Boot application. In the JavaDoc:
Annotation that can be used in combination with
@RunWith(SpringRunner.class)
for a typical JPA test. Can be used when a test focuses only on JPA components. Using this annotation will disable full auto-configuration and instead apply only configuration relevant to JPA tests.By default, tests annotated with
@DataJpaTest
will use an embedded in-memory database (replacing any explicit or usually auto-configured DataSource). The@AutoConfigureTestDatabase
annotation can be used to override these settings. If you are looking to load your full application configuration, but use an embedded database, you should consider@SpringBootTest
combined with@AutoConfigureTestDatabase
rather than this annotation.