Error creating bean with name defaultServletHandlerMapping
Your configuration is fine, except for one place
@ComponentScan(basePackages = { "org.example.springproject" })
I would assume that you have other @Configuration in your package, that's picked up by your @ComponentScan (DelegatingWebMvcConfiguration that appears in your exception is, most likely, imported by @EnableWebMvc somewhere in external @Configuration).
Possible solution is to use a filter in your component scan.
@ComponentScan(basePackages = { "org.example.springproject" }, excludeFilters = { @Filter(type = FilterType.ANNOTATION, value = Configuration.class) })
Class AccountServiceTest
must be injecting a bean with SpingMVC or declared in a config that has SpringMVC enabled. In you project pom.xml, add the javax.servlet-api
dependency to the test scope.
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>test</scope></dependency>