高手请进,小弟刚用spring整合hibernate的时候有点困惑!

2025-04-28 15:32:26
推荐回答(5个)
回答1:

你没有配置数据源,请问你是怎么连接数据库的?

下面是我一个项目中的配置 ,只是作为参考 ,请注意要配置数据源:


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" default-autowire="byName">






























${hibernate.dialect}
${hibernate.show_sql}
${hibernate.format_sql}
${hibernate.hbm2ddl.auto}








com.jinkunxinxi.yousu.core.entity
com.jinkunxinxi.yousu.station.entity


















回答2:

你好。
如果DAO里没有显示编写setter和getter方法的话,就需要继承Hibernate里的一些类,其中就包括sessionFactory的getter和setter方法。

回答3:

你在dao有没有写 sessionFactory的 get set 方法?你的spring 配置没有错误,具体报什么错误你没说。我也不清楚怎么解决

回答4:

我刚接触框架进来看,楼主问问题的话建议到CSDN里问 这边想看你的截图 都很模糊 郁闷

回答5:

什么错误信息啊,你贴出来看看啥