I am trying to test my application using junit.
So I installed the following class:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/META-INF/spring/applicationContext-test.xml" ) @TransactionConfiguration @Transactional public class DispatcherServletTest extends AbstractJUnit4SpringContextTests { private MockHttpServletRequest request; private MockHttpServletResponse response; private DispatcherServlet dispatcher; @Before public void setUp() throws Exception { request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); MockServletConfig config = new MockServletConfig("myapp"); config.addInitParameter("contextConfigLocation","classpath*:webmvc-config.xml"); dispatcher = new DispatcherServlet(); dispatcher.init(config); }
}
So the problem is that my dispatcher servlet cannot send any request to any of my controllers.
I think there is something with the configuration - contextConfigurationLocation. It looks like it can find the file (otherwise it will throw an exception), but does not load the configuration
Logger says:
org.springframework.web.servlet.PageNotFound - no mapping found for HTTP request with URI [http: // localhost: 8080 / myapp / abc]
But I absolutely do not know what happened ...
I would be grateful for any help!
Thank you in advance
source share