开发者

How to config Spring to load hibernate mapping from jar?

My hibernate mapping is in a jar file for example: abc-1.0.1.jar. And the mapping files are: abc-1.0.1.jar/user.hbm.xml.

I can't get spring to load it correctly (I don't want to put my jar version in the mapping also). This is my configuration:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBea开发者_JS百科n">
        <property name="dataSource"><ref local="DS"/></property>
        <property name="hibernateProperties">
           <ref bean="hibernateProperties" />
        </property>     
        <property name="mappingJarLocations" value="classpath*:abc-*.jar"></property>
    </bean>

There is no error at loading but the setting resource is an empty array. Can you help me figure out that is wrong?

Thanks,


It seems you might want to use mappingLocations (JavaDoc) property, instead of mappingJarLocations. In that case, you would just specify classpath:user.hbm.xml:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="DS"/></property>
    <property name="hibernateProperties">
       <ref bean="hibernateProperties" />
    </property>
    <property name="mappingLocations" value="classpath:/user.hbm.xml"/>
</bean>


You can use a wildcard:

<property name="mappingJarLocations" value="WEB-INF/lib/abc-*.jar"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜