1.配置Aop的时候出错了;主要原因是用xml配置aop时,配置before的时候,before是带参数的,没配好少配了and args(user)。
<aop:before method="before" arg-names="user" pointcut="execution(public * cw.ok.spring.aop.*.add*(..)) " />
<aop:before method="before" arg-names="user" pointcut="execution(public * cw.ok.spring.aop.*.add*(..))and args(user)" />
错误:Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao1' defined in file [D:\Workspaces\MyEclipse 8.5\Sprin……
一般applicationContext.xml中配置AOP的时候没配好就会出这样的问题!
2.配置spring整合hibernate时,配数据源 驱动时<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >没有加入相关的包;少了两个包:commons-pool.jar 和commons-dbcp.jar 。
xml提示错误:Class 'org.apache.commons.dbcp.BasicDataSource' n;
3.配置spring事务管理的时候,报错:
spring aop报错:Cannot proxy target class because CGLIB2 is not available.
原因是:没导入jar包
导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar
4.本来是建一个person表,老是出错!寻找了很多时间的错误,原来是数据库中已经存在了person这张表,而且是外键关联,是无法直接删它的,以后建表之前一定要先看数据库中是否已经存在这种表名,或者是保留字段!
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert:
Caused by: org.hibernate.exception.SQLGrammarException: could not insert: [cw.ok.test.po.Person]
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'age' in 'field list'