spring mvc-springmvc配置mysql哪里错了,求大神帮忙

问题描述

springmvc配置mysql哪里错了,求大神帮忙

db.properties:
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://114.215.207.30:3306busticket?useUnicode=true&characterEncoding=UTF-8
username=PBDB
password=PBDB

springmvc-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
">

<!-- 设置spring的注解扫描路径 -->

<!-- 配置spring mvc放行静态资源
-->
<mvc:resources location="/js/" mapping="/js/*.js"></mvc:resources>

<!-- 注解驱动器 简写 -->
<mvc:annotation-driven></mvc:annotation-driven>
  <!-- 引入外部资源文件 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations" value="classpath:db.properties"></property>
</bean>

<!-- 数据源的配置 使用的是commons-dbcp数据源 另外还有cp30和proxool数据源可以选用-->

<tx:annotation-driven transaction-manager="transactionManager"/>

严重: Servlet.service() for servlet [springmvc] in context with path [/Test] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver '

The error may exist in com/aowin/dao/CardMapper.xml

The error may involve com.aowin.dao.CardMapper.select

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver '] with root cause

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:66)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:271)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
at com.sun.proxy.$Proxy14.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at com.sun.proxy.$Proxy15.select(Unknown Source)
at com.aowin.service.imp.SelectImp.select(SelectImp.java:53)
at com.aowin.controller.CardController.chong(CardController.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

解决方案

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver ,看到这你就应该知道是什么错了吧

解决方案二:

确定一下mysql驱动包你有没有?还有驱动的版本对不对

解决方案三:

:3306busticket 你确定端口和数据库之间不要 / classnotfind 说明的的连接mysql的jar包没有啊

解决方案四:

把mysql-connector-java-bin.jar拷贝到tomcat下lib目录试试

解决方案五:

url也错了吧,3306后面是不是少了斜杠啊

解决方案六:

url错误 另外缺少mysql的驱动包mysql-connector-java-bin.jar 把驱动包考到lib下

解决方案七:

下面是本人面试时候要求做的小系统,里面有标准spring mvc搭建的项目可以参考。
http://download.csdn.net/detail/xiaoyao880609/9475599

解决方案八:

Cannot load JDBC driver class 'com.mysql.jdbc.Driver '
The error may exist in com/aowin/dao/CardMapper.xml
The error may involve com.aowin.dao.CardMapper.select

没找到数据库驱动,com/aowin/dao/CardMapper.xml 检查数据库驱动那块是否写错 ,com.aowin.dao.CardMapper.select sql 是否正确

解决方案九:

:3306busticket 你确定端口和数据库之间不要 / classnotfind 说明的的连接mysql的jar包没有啊

解决方案十:

少JDBCjar包。。。。。。

时间: 2024-11-08 17:13:36

spring mvc-springmvc配置mysql哪里错了,求大神帮忙的相关文章

springMVC配置报错,求大神帮忙

问题描述 springMVC配置报错,求大神帮忙 解决方案 解决方案二: 解决方案三: 解决方案四: 解决方案五: No mapping found for HTTP request with URI [/demo/index.html] in DispatcherServlet with name 'spring' 说的很明白了 解决方案六: 建立也demo文件夹,把index.html挪进去. 解决方案七: RequestMapping("/demo/*")试试

求大神帮忙啊,初次整合spring mvc 和mybatis 就遇到了这么烫手的山芋

问题描述 求大神帮忙啊,初次整合spring mvc 和mybatis 就遇到了这么烫手的山芋 用Mybatis 逆向工程得出model 和Mapper 以及mapper.xml 在网页中测试,网页一直处于正在连接状态,后台前台都不报错,单步调试报 not available native method! 解决方案 逐一在controller中打断点,再调试试试. 初步判断可能是数据库连接配置文件的问题,导致数据库连接获取不到.建议检查下数据库连接配置属性. 解决方案二: 解决方案三: 好好检查

spring mvc 事务,操作多张表的时候,异常不回滚,求大神帮忙啊

问题描述 spring mvc 事务,操作多张表的时候,异常不回滚,求大神帮忙啊 @Override @Transactional(rollbackFor=Exception.class) public Boolean saveXkcq(String qian,String xh, Xk_cqb cqb, Rw_xkb rwXkb, Xk_xkb xkb) { Boolean type = false; try { if(qian!=null && qian.length()>0){

spring+springmvc+mybatis 报错。求大神指教。

问题描述 spring+springmvc+mybatis 报错.求大神指教. 严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'index': Injection of autowired dependencies failed; nested exception is org.springframework.b

运行springmvc框架过程中遇到的问题,求大神帮忙!

问题描述 运行springmvc框架过程中遇到的问题,求大神帮忙! 八月 31, 2015 9:28:48 上午 org.apache.catalina.core.ContainerBase startInternal 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start c

jar-web启动出错了,求大神帮忙看下!!

问题描述 web启动出错了,求大神帮忙看下!! 谁知道是怎么回事啊.看不懂求解释 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in URL [jar:file:/G:/apache-tomcat-7.0.59/webapps/llsfw-web/WEB-INF/lib/llsfw-core-

编程-跪求大神帮忙看下代码,错了不晓得怎么改哦

问题描述 跪求大神帮忙看下代码,错了不晓得怎么改哦 switch (uMsg) { case WM_CHAR: char szChar[20]; sprintf(_T(szChar),_T( "char code is %d"), wParam); 错误 1 error C2065: "LszChar": 未声明的标识符 IntelliSense: "const wchar_t *" 类型的实参与 "const char *"

win8-关于mysql的问题,百度上面很多方法我都照着做了,可是还是不行,求大神帮忙看看那

问题描述 关于mysql的问题,百度上面很多方法我都照着做了,可是还是不行,求大神帮忙看看那 我是win8的系统,下载的5.7.10版本,在官网上下载的zip. 有两个问题:1.我在my.ini文件中已经添加了 skip_grant_tables 但是 登陆的时候还是有错误,上图: 2.输入net start mysql启动不了 !图片说明 解决方案 mysql的系统服务是否注册成功,不然net start启动不了 数据库root用户密码是否配置正确 解决方案二: 你确定安装mysql有这么复杂

求大神帮忙 spring aop 方式事务不回滚怎么搞?

问题描述 求大神帮忙 spring aop 方式事务不回滚怎么搞? spring 版本 4.1.7 代码如下: 表: CREATE TABLE users (id int(11) unsigned NOT NULL AUTO_INCREMENT,nick_name varchar(100) DEFAULT NULL,password varchar(100) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAU