IDEA ssm框架学习
1.问题处理
JUnit测试报错:Class not found me.gacl.test.MyBatisTest
1.具体报错信息如下:
Class not found me.gacl.test.MyBatisTest
java.lang.ClassNotFoundException: me.gacl.test.MyBatisTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:499)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
解决办法:
修改eclipse代码提示级别
Preferences–Java–compiler–building
2.问题
Servlet.service() for servlet [DispatcherServlet] in context with path [/Hospital_war] 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 create PoolableConnectionFactory (Access denied for user ‘dell’@‘localhost’ (using password: YES))
The error may exist in com/hospital/UserMapper.xml The error may involve com.hospital.dao.UserMapper.findUserByUsername
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 create PoolableConnectionFactory (Access denied for user ‘dell’@‘localhost’ (using password: YES))] with root cause
解决办法:是因为Spring4.0以后的db.properties配置出错
具体参考参考文章https://www.tuicool.com/articles/BF7RJb
3.注意dao曾的mapper和映射文件名必须一致