关于hibernate的配置文件在Spring中的设置问题

材料来源:http://www.blogjava.net/caixuetao/articles/37790.html

通常在spring中会这么写代码 mappingResources
< bean id = " sessionFactory "   class = " org.springframework.orm.hibernate.LocalSessionFactoryBean " >
< property name = " mappingResources " >
< list >
< value > Student.hbm.xml </ value >
< value > Course.hbm.xml </ value >

</ list >
</ property >

</ bean >
如果X.hbm.xml文件很多时,则写起来会很不方便,可以像下面这种写法就简单多了:(其中假设所有的.hbm.xml文件都存于com/model目录) mappingDirectoryLocations
< bean id = " sessionFactory "   class = " org.springframework.
orm.hibernate.LocalSessionFactoryBean " >
< property name = " mappingDirectoryLocations " >
< list >
< value > classpath: / com / model </ value >
</ list >
</ property >

</ bean >
写到这里,看到classpath,想起以前整合SSH时,在web.xml中也使用过classpath来简化
  < context-param >
         < param-name > contextConfigLocation </ param-name >
        < param-value > classpath:applicationContext.xml </ param-value >
 </ context-param >

猜你喜欢

转载自6tao.iteye.com/blog/1109376