一、
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
原因:idea自动过滤掉了src/main/java下的配置文件,因为一般配置文件都是放在src/main/resource下的。
解决方法:将*Mapper.xml复制进去
二、
java.lang.NullPointerException
at Test.Test(Test.java:25)
原因:spring中JUnit4单元测试时需要在测试类中添加注解
解决方法:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/spring-main.xml")
三、
//
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userserviceImpl': Unsatisfied dependency expressed through field 'userMapping'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapping' defined in file [E:\项目_java工作\whadmin\target\classes\cn\ect\sys\mapper\UserMapping.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-main.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
原因:pom中没有添加spring-jdbc的jar包
解决方法:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
四、
[INFO][2019-08-06 12:43:51,825][com.alibaba.druid.pool.DruidDataSource]{dataSource-1} inited
[ERROR][2019-08-06 12:43:52,245][com.alibaba.druid.pool.DruidDataSource]create connection SQLException, url: jdbc:mysql://127.0.0.1:3306/whadmin?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8, errorCode 1045, state 28000
java.sql.SQLException: Access denied for user 'Timor'@'localhost' (using password: YES)
原因:数据库链接异常(spring配置异常、或者db.properties异常)
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
解决方法:改改改spring配置或者db.properties文件
五、
六、
七、
八、