Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring class not found when it exists

I'm getting an exception that "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" does not exist in my WebContent\WEB-INF\spring-dispatcher-servlet.xml file. I have the spring-webmvc 4.1.2 dependency added and I the class exists in my maven dependencies so it's as though it isn't seeing those classes from my maven dependencies?

    <bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
like image 535
jn025 Avatar asked Oct 18 '25 15:10

jn025


2 Answers

If you are using eclipse, try clean project, and then clean Tomcat directory. Also make sure that maven dependencies are present in WEB-INF/lib, if not, this is configurable from Project Properties > Deployment Assembly

like image 123
outdev Avatar answered Oct 20 '25 05:10

outdev


You probably have multiple versions of spring-webmvc on your classpath as dependencies of other direct dependency. Call mvn dependency:tree -Dverbose -Dincludes=spring-webmvc to see how many versions of the library you have and exclude older versions.

Or, if you are using Intellij, enable the maven plug-in, generate diagram, search with Ctrl-F for spring-webmvc and where you have older dependency right click on it and choose exclude. Probably eclipse has similar functionality too.

like image 26
Random42 Avatar answered Oct 20 '25 05:10

Random42