I’m writing a pretty simple Spring boot 3.1.1 application with Spring Batch, H2 and Data JPA.
My application works fine when lauching main()
method and can access H2 webapp console
When launching integration test with @SpringBootTest
, it works fine too but… but I cannot access h2-console http://localhost:8080/h2-console/
Here’s my test class :
@SpringBootTest
@SpringBatchTest
class BankBatchApplicationTests {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Test
void contextLoads() throws Exception {
JobExecution jobExecution = jobLauncherTestUtils.launchJob();
assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
}
}
Here are my logs when launching test :
2024-04-25T17:37:40.760+02:00 INFO 24840 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb2'
My application.properties
in src/test/resources
is exactly the same as in src/main/resources
and includes this property : spring.h2.console.enabled=true