Exception和解决方案

org.hibernate.HibernateException: No Session found for current thread

  • sessionFactory
    • org.springframework.orm.hibernate4.LocalSessionFactoryBean
  • Hibernate4 与 spring3 整合使用注解注入sessionFactory,SessionFactory的getCurrentSession并不能保证在没有当前Session的情况下会自动创建一个新的,这取决于CurrentSessionContext的实现
  • 解决方案
    1. session.openSession()
    2. 用transactionManager管理session,注解@Transactional(value="transactionManager", readOnly=true)

       <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
           <property name="sessionFactory" ref="sessionFactory">
           </property>
       </bean>

@Transactional不起作用

配置文件必须加annotation-driven,否则不解析@Transactional

<tx:annotation-driven />

Injection of autowired dependencies failed;

nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field:
expected single matching bean but found 2:
  • spring @Autowired有多个子类实现报错
  • 解决方案 :
    • 用@Resource(name="") 代替@Autowired

设置 -Xmx后进程实际占用内存超出

进程除了JVM heap外 还有别的Native对象占用内存,Native对象不受JVM管理

java.lang.IllegalArgumentException: XPP3 pull parser library not present. Specify another driver. For example: new XStream(new DomDriver())

  • 解决方案
    1. 加入 gficore_all.jar

Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory

  • 有可能是由于java编译版本和运行版本的差异造成的Bean销毁
  • 也有可能是JVM OOM导致

Context namespace element 'component-scan' and its parser class [org.springframework.context.annotat

  • 就是spring的版本太低了(我当时用的spring2.5)spring2.5出来的时候,jdk1.8还没有出来,所以spring2.5不支持jdk1.8

转载于:https://www.cnblogs.com/judesheng/p/10649989.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值