MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 讨论:Eclipse+Spring+Hibernate配置中的路径有关问

讨论:Eclipse+Spring+Hibernate配置中的路径有关问题(分不够开新贴给分)

www.MyException.Cn  网友分享于:2015-08-27  浏览:48次
讨论:Eclipse+Spring+Hibernate配置中的路径问题(分不够开新贴给分)
小第刚开始搞Spring,在Eclipse环境下开发。

/WEB-INF/web.xml配置

<display-name> ims </display-name>
<context-param>
    <param-name> contextConfigLocation </param-name>
    <param-value> /WEB-INF/applicationContext.xml </param-value>
</context-param>
<context-param>
    <param-name> log4jConfigLocation </param-name>
    <param-value> /WEB-INF/log4j.properties </param-value>
</context-param>
 
<listener>
    <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class>
</listener>
<listener>
    <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>

在/WEB-INF/applicationContext.xml配置如下
<bean   id= "propertyConfigurer "   class= "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">
<property   name= "location "   value= "/WEB-INF/jdbc.properties "   />
</bean>

<bean   id= "dataSource "
class= "org.springframework.jdbc.datasource.DriverManagerDataSource ">
<property   name= "driverClassName "   value= "${jdbc.driverClassName} "   />
<property   name= "url "   value= "${jdbc.url} "   />
<property   name= "username "   value= "${jdbc.username} "   />
<property   name= "password "   value= "${jdbc.password} "   />
</bean>

<!--   JNDI   DataSource   for   J2EE   environments   -->
<!--
<bean   id= "dataSource "   class= "org.springframework.jndi.JndiObjectFactoryBean ">
<property   name= "jndiName "   value= "java:comp/env/jdbc/petclinic "/>
</bean>
-->

<!--   Hibernate   SessionFactory   -->
<bean   id= "sessionFactory "
class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean ">
<property   name= "dataSource "   ref= "dataSource "   />
<property   name= "mappingResources ">
<value> hibernate-mapping.hbm.xml </value>
</property>
<property   name= "hibernateProperties ">
<props>
<prop   key= "hibernate.dialect "> ${hibernate.dialect} </prop>
<prop   key= "hibernate.show_sql "> true </prop>
<prop   key= "hibernate.generate_statistics "> true </prop>
<prop   key= "hibernate.hbm2ddl.auto "> update </prop>
</props>
</property>
<property   name= "eventListeners ">
<map>
<entry   key= "merge ">
<bean   class= "org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener "   />
</entry>
</map>
</property>
</bean>

以上代码在不同的应用服务器报的错也不一样,感觉就是hibernate-mapping.hbm.xml、jdbc.properties和applicationContext.xml的路径上出了问题。

请教:在eclipose开发web应用程序时,classpath到底是怎么回事呀?!如果提问不清楚,我再解释。

------解决方案--------------------

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有