Sou novo com spring,ao fazer uma consulta em uma classe dao,aparece o seguinte erro:
meu spring-context.xmlé:
<mvc:interceptors>
<bean class="br.com.softwarescomerciais.os.interceptor.AutorizadorInterceptor"></bean>
</mvc:interceptors>
<mvc:default-servlet-handler/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.101.178/sc"/>
<property name="username" value="sfilho"/>
<property name="password" value="123"/>
</bean>
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: DataSource must not be null
type: Exception report
message: Request processing failed; nested exception is java.lang.IllegalArgumentException: DataSource must not be null
description: The server encountered an internal error that prevented it from fulfilling this request.
例外:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: DataSource must not be null
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
根本原因:
java.lang.IllegalArgumentException: DataSource must not be null
org.springframework.util.Assert.notNull(Assert.java:112)
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.<init>(NamedParameterJdbcTemplate.java:89)
br.com.softwarescomerciais.os.dao.UsuarioDao.existe(UsuarioDao.java:27)
br.com.softwarescomerciais.os.controller.LoginController.efetuaLogin(LoginController.java:34)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)