[java网文系列一]SSH整合常出现问题

1、org.springframework.beans.NotWritablePropertyException(很畸形的bug)

出现异常的原因是在application-xxx.xml中property name的错误。
  <property name="....">中name的名字是与bean的set方法相关的,而且要注意大小写。一般第二个字母不能大写
  比如

public class PostManageImpl extends BaseManage implements PostManage {
private PostDAO dao = null;
public void setPostDAO(PostDAO postDAO){
this.dao = postDAO;
}
}



  那么xml的定义应该是:

<bean id="postManage" parent="txProxyTemplate">
<property name="target">
 <bean class="com.yz.spring.service.implement.PostManageImpl">
  <property name="postDAO"><ref bean="postDAO"/></property>对
  <property name="dao"><ref bean="postDAO"/></property>错
 </bean>
</property>
</bean>


2、Struts中的DispatchAction中提交jsp中请求事件不能跳转到指定页面

原因是在DispatchAction中存在execute方法,Action会优先执行此方法而不会按照url传过来的method方法执行,所以千万注意此处

3、Field 'id' doesn't have a default value

原因是数据库中id属性值没有让它“自动增长”

4、could not initialize proxy - no Session
Hibernate3 错误: could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
原因:
hibernate3 many-to-one的默认选项是 lazy = "proxy"
解决方法:
<many-to-one> & <one-to-many> 中设置 lazy="false"

5、在使用Jbpm工作流引擎的时候,Hibernate配置文件一定要加上属性

<property name="hibernate.hbm2ddl.auto">update</property>

Hbm2dll.auto是数据库表和类自动连接更新

6、jbpm与Spring整合报错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmConfiguration' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key jbpmConfiguration

解决方法:去掉struts-config.xml文件中的org.springframework.web.struts.ContextLoaderPlugIn,也就是与Spring整合的插件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值