• HTTP Status 500


    HTTP Status 500 - Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. type Exception report message Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTOor remove 'readOnly' marker from transaction definition.

    description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

    org.springframework.orm.hibernate5.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1126) org.springframework.orm.hibernate5.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:619) org.springframework.orm.hibernate5.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:616) org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:341)

     .....

    HTTP状态500-写入操作不允许在只读模式(FlushMode.MANUAL)中进行:将会话转换为FlushMode.COMMIT/AUTO,或从事务定义中删除“readOnly”标记。

    错误原因:

    代码中使用了@Transactional注解事务,因为你没有在applicationContext.xml中配置事务自动扫描,而使用了默认的只读模式,不能随代码运行自动刷新,

    更正方法:

    在applicationContext.xml文件中增加配置:

        <!--配置事务管理器 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
        <!-- 开启事务扫描,采用注解方式 -->
        <tx:annotation-driven transaction-manager="transactionManager" />

    每天分享一个错误,快乐成长每一天!

  • 相关阅读:
    03继承与多态 动手动脑
    data whitening
    特征值和特征向量
    CRC算法
    python 二维字典
    协方差的计算与理解
    Differences between write through and write back
    Differences between page and segment
    虚拟内存和缓存区别
    Python: 统计一个文件中每个单词出现的次数
  • 原文地址:https://www.cnblogs.com/niusdtz/p/9625926.html
Copyright © 2020-2023  润新知