zoukankan      html  css  js  c++  java
  • 关于错误:Javassist Enhancement failed: com.spring.oa.domain.Person的解决办法

    出现这个错误的原因我在网上查了一下,大多数的解决办法都用了一下,才解决了这个问题,我就在这里总结一下我用到的方法:

    1.javassist  jar包重复问题:

       当你使用hibernate和struts2的jar包时,两个框架里面都用到了javassist,所以,当你一股脑全部copy到项目里面就会出现重复,导致上述问题,请把一个删掉就可以运行了,另外:

    javassist3.15版本据说有bug,所以最好使用更高级的版本。

    2.我删除了重复包之后仍有报错,所以我采取了别的解决办法:

    (1)在hbm,xml文件中加入以下代码

    <class name="com.spring.oa.domain.Person">
            <id name="id">
                <generator class="increment"></generator>
            </id>
            <property name="name">
                <column name="name"></column>
            </property>
            <many-to-one name="person" class="Person" column="id" lazy="false"/> 
        </class>

    注意要把懒加载设置为false。

    同时在web.xml文件中加入拦截器

     <filter>
            <filter-name>OpenSessionInViewFilter</filter-name>
            <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>OpenSessionInViewFilter</filter-name>
            <url-pattern>*.action</url-pattern>
        </filter-mapping>

    注意:要把这段代码放在strut2的配置前面。

    通过上述问题解决了我题目中的问题,不过又出现了新的bug:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' 
    defined in class path resource [spring/applicationContext-db.xml]: Invocation of init method failed;
    nested exception is org.hibernate.MappingException: An association from the table Person refers to an unmapped class: Person

    不说了,先去百度了

  • 相关阅读:
    C & 指针
    分析Android (build/core/*.mk脚本)
    C#.net调用axis2webService
    MongoDB 配置文件启动
    mongodb 简单部署方案及实例
    MongoDB 权限认证
    MongoDB索引介绍
    mongodb 全文检索
    MongoDB 覆盖索引查询
    mongodb MongoDB 聚合 group
  • 原文地址:https://www.cnblogs.com/dengkaien/p/7928166.html
Copyright © 2011-2022 走看看