iteye_15334 2010-07-01 21:44 采纳率: 100%
浏览 514
已采纳

spring、hibernate整合出现“does not denote a directory”

在整合spring、hibernate时,mapping映射文件出现does not denote a directory错误。

错误日志:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Mapping directory location [file [F:\workspace\hr\HrSystem\bin\com\zhueli\soft\hr\entity\HrAccount.hbm.xml]] does not denote a directory

配置文件applicationContext.xml
[code="java"]<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:dbinit.properties</value>
        </list>
    </property>
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                ${hibernate.dialect}
            </prop>
            <prop key="hibernate.show_sql">
                ${hibernate.show_sql}
            </prop>
            <prop key="hibernate.cache.use_query_cache">
                ${hibernate.cache.use_query_cache}
            </prop>
            <prop key="hibernate.cache.provider_class">
                ${hibernate.cache.provider_class}
            </prop>
        </props>
    </property>

    <property name="mappingDirectoryLocations">
        <list>
            <value>
                classpath*:/com/zhueli/soft/hr/entity/*.hbm.xml
            </value>
        </list>
    </property>
    <property name="lobHandler" ref="lobHandler" />
</bean>

<bean id="lobHandler" lazy-init="true"
    class="org.springframework.jdbc.support.lob.DefaultLobHandler" />
<aop:config>
    <aop:advisor
        pointcut="execution(* com.zhueli.soft.hr.service.*.*(..))"
        advice-ref="txAdvice" />

    <aop:advisor
        pointcut="execution(* com.zhueli.soft.hr.*.*.service.*.*(..))"
        advice-ref="txAdvice" />
    <aop:advisor
        pointcut="execution(* com.zhueli.soft.hr.*.service.*.*(..))"
        advice-ref="txAdvice" />
    <aop:advisor
        pointcut="execution(* com.zhueli.soft.hr.*.*.*.service.*.*(..))"
        advice-ref="txAdvice" />
</aop:config>

<tx:advice id="txAdvice">
    <tx:attributes>
        <tx:method name="insert*" />
        <tx:method name="save*" />
        <tx:method name="create*" />
        <tx:method name="add*" />
        <tx:method name="update*" />
        <tx:method name="modify*" />
        <tx:method name="delete*" />
        <tx:method name="remove*" />
        <tx:method name="send*" />
        <tx:method name="do*" />
        <tx:method name="*" read-only="true" />
    </tx:attributes>
</tx:advice>

<bean id="baseDao" class="com.zhueli.soft.hr.db.BaseDaoImpl">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<import resource="classpath:dataAccessContext-local.xml" />

[/code]

经检查项目不存在中文,实体类目录也确实生成了。

  • 写回答

2条回答 默认 最新

  • iteye_8679 2010-07-02 08:58
    关注







    [color=red]classpath*:/com/zhueli/soft/hr/entity/*.hbm.xml [/color]






    [b]你这个地方写的不对吧,mappingDirectoryLocations属性说的就是目录位置,你为什么还要*.hbm.xml 呢,指定到目录就可以了classpath*:/com/zhueli/soft/hr/entity/[/b]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏