hibernate session.save();没执行,也没报错。我把我的配置反正下面请看看。
<context:annotation-config/><context:component-scanbase-package="com.test"/>-<beanid=...
<context:annotation-config />
<context:component-scan base-package="com.test" />
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/zg_helper" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- <property name="dataSource">
<ref bean="dataSource" />
</property>
- <property name="hibernateProperties">
- <props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
</props>
</property>
- <property name="annotatedClasses">
- <list>
<value>这里是配置的实体</value>
</list>
</property>
</bean>
sessionFactory 是用注解注入的,看图片 展开
<context:component-scan base-package="com.test" />
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/zg_helper" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- <property name="dataSource">
<ref bean="dataSource" />
</property>
- <property name="hibernateProperties">
- <props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
</props>
</property>
- <property name="annotatedClasses">
- <list>
<value>这里是配置的实体</value>
</list>
</property>
</bean>
sessionFactory 是用注解注入的,看图片 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询