Spring Boot Application scenarios to Load ApplicationContext with JPA Transactions
I'm sure I'm missing something obvious here, but I'm working with an scenario when trying to run my Spring Boot application that's failing to load the ApplicationContext. I am using Spring Boot version 2.5.4 along with Spring Data JPA for database interactions. The application works fine in my local development environment but fails during integration testing on my CI/CD pipeline. The behavior message I receive is: ``` org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean ``` This seems related to my usage of JPA transactions as I have configured Spring to manage transactions via `@EnableTransactionManagement`. Here is a snippet of my configuration: ```java @Configuration @EnableTransactionManagement public class JpaConfig { @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[]{"com.example.models"}); return em; } @Bean public PlatformTransactionManager transactionManager(EntityManagerFactory emf) { return new JpaTransactionManager(emf); } @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("org.h2.Driver"); dataSource.setUrl("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); dataSource.setUsername("sa"); dataSource.setPassword(""); return dataSource; } } ``` I've verified that all necessary dependencies are included in my `pom.xml`, specifically: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> ``` In my test classes, I am using `@SpringBootTest` to load the context, and I have also tried adding `@Transactional` to my test methods. However, I still encounter the same behavior. I've also checked the logs to see if there's any indication of a missing bean or misconfiguration but found nothing helpful. Could this scenario be related to the way I'm initializing the application context in my tests, or is there something else I might be missing? Any insights or suggestions would be greatly appreciated! This is part of a larger CLI tool I'm building. I'd really appreciate any guidance on this.