1. java.lang.OutOfMemoryError: PermGen space
-XX:MaxPermSize=256m
关键是这个参数,你的myeclipse,启动tomcat的那个图标旁边的三角拉下来,选configure server,然后从server里找到你的tomcat7下的JDK一项,填到那个栏里。
PermGen space是内存里分配的永久保存区域,就是启动JVM时,用来存放class的地方,你的项目太大,class和配置太多,这块地方就会放不下,所以要设置MaxPermSize
2.Null value was assigned to a property of primitive type setter
解决办法:
<property name="provinceOrderMember" type="int">
<column name="provinceOrderMember">
<comment></comment>
</column>
</property>
type="int" 改为type="java.lang.Integer"
private int provinceOrderMember; 改为private Intege provinceOrderMember
原因:数据库字段值为NULL,int 类型不能赋值为NULL,只能为0,但有些实际应用中,如学生分数,0表示0分,NULL,则表示暂无分数所以,要不设数据字段不为NULL,要不就是用Integer.
3.hibernate4 Error applying BeanValidation relational constraints
解决办法:由于javax.persistence.validation.mode的属性值默认是auto,所以会出错。
在hibernate.cfg.xml里将javax.persistence.validation.mode设置为none,就可以避免出错了。
<!-- Disable the BeanValidation -->
<property name="javax.persistence.validation.mode">none</property>
如果不设置mode,就会出现以下的错误信息:
Initial SessionFactory creation failed.org.hibernate.HibernateException: Error applying BeanValidation relational constraints
4.
在struts2,spring整合时出现了如下问题,搜了好长时间,问了好多大神:
UserDao是接口,而换成实现它的UserDaoImpl类型就不对 了,出错信息说类型不对 ???
Unable to instantiate Action, com.login.action.LoginAction, defined for 'acm' in namespace '/'Error creating bean with name 'com.login.action.LoginAction': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userDao' must be of type [com.login.dao.impl.UserDaoImpl], but was actually of type [$Proxy27]在控制层用resource注入service 而service中用了@Transaction注解时
报 Bean named 'xxxService' must be of type [com.xxx.xxxService], but was actually of type [$Proxy6]错误 解决如下:
1.应注入service的接口而非实现类
2.设置proxy-target-class="true" <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>加入cglib包
在spring中@Transaction是通过AOP实现的,而spring对AOP有两种实现方式,一种是动态代理,它是通过接口方式实现的,要求所代理的类一定是实现了某一个接口,对一般的类就无法代理,spring默认是这种;通过设置proxy-target-class="true",则是使用CGLIB实现AOP,CGLIB直接生成二进制码,使得普通类也可以实现AOP。在没有设置proxy-target-class="true"时,使用动态代理,是一个临时生成的类,如proxy17,它不是@Resource指定的类,因此出现了上述错误
5.java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
用的是hibernate4 与spring3
HibernateDaoSupport这个没有了,在使用hibernateTemplate的时候,报错误java.lang.NoSuchMethodError:org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session
对于HibernateTemplate ,spring 3.0已经建议不再使用了……
6.在Spring @Transactional声明式事务管理的配置中,hibernate.current_session_context_class=thread这一句是不能加的…
加了就会出错..那为什么不能加呢?
那是因为在Spring事务管理中,current Session是绑定到SpringSessionContext中的,而不是ThreadLocalSessionContext中的