在做ssh项目的时候,发现执行到getHibernateTemplate().save()方法后,没有执行成功,如下图:
调试发现源码中抛出了一个异常: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.
发现应该是与事务有关,我的事务是配置在aplicationContext.xml中,于是去配置文件中查看事务的配置,发现:
我的类名后缀是Impl,而配置文件中是Imp,修改后运行成功