1) Invalid bound statement (not found)错误
检查文件AreaDao.xml中mapper标签的namespace属性的值,正确值为[AreaDao]的全限定名,而不是它的包名
2) java.io.FileNotFoundException: class path resource [classpath*:/mapper/**.xml] cannot be opened because it does not exist错误
检查SessionFactoryConfiguration类中sqlSessionFactoryBean.setMapperLocations的传值 正确为[resolver.getResources]最后的[S]很容易代码提示的时候选错 选成[resolver.getResource] 两者区别在于单文件和多文件。classpath*:/mapper/**.xml 最后的**.xml是该路径下所有的*.xml文件的写法 所以新手一定要严格注意,仔细检查代码!!!
3) 关于mybatis-config.xml配置文件的相关错误
关于该文件出现的错误参考解决思路如下
①请仔细检查文件的层级! 该文件所处的正确位置应为[src/main/resources]下
②检查xml文件中的约束的正确性(PS:新人有时候往往会迷之自信 有些时候看教程手敲代码不要相信自己的眼睛!!!! 懒人可以复制下方代码)
---------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
---------------------------------------------------------------------------------------------------------
③检查3个setting标签的name属性 三个name属性具体如下 可以复制粘贴 原因同上: 不要迷之自信
useGeneratedKeys
useColumnLabel
PS: 此处 useColumnLabel 非常容易写成 useColumnLable Label和Lable 傻傻分不清楚?
mapUnderscoreToCamelCase
如遇到其他问题 欢迎反馈追问 看到即回复
最后啰里啰嗦下: 新人很多时候看教程往往回迷之自信 这个教程适用于有Spring MVC功底的人学习SpringBoot的 不完全适应新人小白 强烈建议深度学习Spring 尤其是IOC和AOP方面 建议配合源码学习(PS:懂得底层源码的原理结构 往往可以让你快速找到解决问题的思路) 遇到BUG不要慌 冷静下来滤清思路往往比干着急要强很多 作为一名合格的成年的程序员 要学会控制自己的情绪 往往遇到BUG才是最好的 一帆风顺反而对未来不是很好 每一次解决BUG的过程才是你真正成长的过程 最后希望大家共同进步 一起努力向前
java.sql.SQLSyntaxErrorException: Unknown database 'tb_area'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:827) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) ~[mysql-connector-java-8.0.17.jar:8.0.17]
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) ~[c3p0-0.9.5.2.jar:0.9.5.2]
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) [mchange-commons-java-0.2.11.jar:0.2.11]
2019-10-12 16:02:43.073 WARN 9036 --- [HelperThread-#0] c.m.v2.resourcepool.BasicResourcePool : com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@68b9190f -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
请问您一下,这是什么原因?我完全按照教程来的
1) Invalid bound statement (not found)错误
namespace属性值填写的是权限定名,还是报错,百度里面的方法也检查过了,还是不行
在这里找到了bug谢谢
这不是提问 是解决办法 ↑↑↑点击上方标题↑↑↑ 里面有相应解决办法