Answer the question
In order to leave comments, you need to log in
How to add a ServletWebServerFactory bean?
There is a test:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ProjectRepository.class, ProjectController.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
public class ProjectRestControllerIntegrationTest {
@Bean
ServletWebServerFactory servletWebServerFactory(){
return new TomcatServletWebServerFactory();
}
@Autowired
private MockMvc mockMvc;
@Autowired
private ProjectRepository projectRepository;
@Autowired
private ProjectController projectController;
@Test
public void contexLoads() throws Exception {
assertThat(projectRepository).isNotNull();
assertThat(projectController).isNotNull();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question