Hibernate 当我使用SpringMVC+;冬眠+;雄猫
我正在使用SpringMVC+hibernate+tomcat创建一个webapp。当我启动tomcat时,没有错误或警告。网站正常。但当我提交一些数据时,chrome一直挂起。tomcat日志中没有错误。我正在学习使用SpringMVC。 Spring-config.xml:Hibernate 当我使用SpringMVC+;冬眠+;雄猫,hibernate,spring-mvc,Hibernate,Spring Mvc,我正在使用SpringMVC+hibernate+tomcat创建一个webapp。当我启动tomcat时,没有错误或警告。网站正常。但当我提交一些数据时,chrome一直挂起。tomcat日志中没有错误。我正在学习使用SpringMVC。 Spring-config.xml: <context:component-scan base-package="com.gujiaqi" use-default-filters="false"> <context:include-
<context:component-scan base-package="com.gujiaqi" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
spring-controller.xml:
<context:component-scan base-package="com.gujiaqi" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
<!-- ... -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/page/"/>
<property name="suffix" value=".jsp"/>
</bean>
spring-hibernate.xml:
<!-- 配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://127.0.0.1/springmvc" />
<property name="username" value="soho" />
<property name="password" value="123456" />
</bean>
<!-- 配置hibernate SessionFactory-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hiberante.format_sql">true</prop>
</props>
</property>
<property name="packagesToScan">
<!-- 这里为SessionFactory配置了实体bean的自动扫描 -->
<list>
<value>com.gujiaqi.bean</value>
</list>
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--启动spring注解功能-->
<tx:annotation-driven transaction-manager="transactionManager" />
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* com.gujiaqi.service.impl.*.*(..))" />
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
<!-- 事务代理类 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="create*" propagation="REQUIRED"/>
<tx:method name="do*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="get*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
org.hibernate.dialogue.mysqldialogue
更新
真的
真的
com.gujiaqi.bean
个人资料中有错误吗
可能我的英语不好,问题也不清楚。挂起的服务方式是什么样的?尝试执行此操作以进一步调试:
- 在被调用的服务层方法上放置一个断点,以查看它是否被调用
- 让它挂起,暂停调试器,然后在调试器视图上查看每个线程的堆栈,查看线程正在做什么。大多数将处于非活动状态,但其中一个将运行对您的服务的呼叫。书堆会告诉你为什么它挂着
- 查看数据库发生了什么,打开了多少个会话,它们是否被阻止等,使用
- 增加spring和hibernate的日志记录级别以进行调试
如果仍然卡住,您能否发布进一步的结论和服务方法代码本身 这是交易的问题,我会解决的。