最近在配置spring4+hibernate4时,
报错
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.
我试过了网络上各种帖子但是都没有效果,当我设置flushModel时,则报另外一种错误。折腾三四天了一直没效果
下图是我的spring配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="url"
value="jdbc:mysql://localhost:3306/factory?useUnicode=true&characterEncoding=utf-8">
</property>
<property name="username" value="root"></property>
<property name="password" value=""></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
<prop key="hibernate.format_sql">
true
</prop>
<prop key="hibernate.hbm2ddl.auto">
update
</prop>
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>
<prop key="current_session_context_class">thread</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.sven.entity.SwMember</value></list>
</property>
<property name="mappingResources">
<list>
<value>com/sven/entity/SwMember.hbm.xml</value>
<value>com/sven/entity/SwArticle.hbm.xml</value></list>
</property></bean>
<bean id="memberService" class="com.sven.service.impl.SwMemberServiceImpl">
<property name="memberDao">
<ref bean="memberDao"/>
</property>
</bean>
<bean id="memberDao" class="com.sven.dao.impl.SwMemberDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="articleService" class="com.sven.service.impl.SwArticleServiceImpl">
<property name="articleDao">
<ref bean="articleDao"/>
</property>
</bean>
<bean id="articleDao" class="com.sven.dao.impl.SwArticleDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
事务我配置了也是不行,
一直提示read-only,设置为false也不行。
求大神指点问题在哪?
题主能不能提供下调用报错类的代码截图,service层的那个调用类,看配置应该是articleService