我正在使用与Spring集成的Hibernate,请在下面找到SessionFactory
的bean,一切都在Eclipse中运行良好,但是,在编译到jar之后无法获得sessionFactory({{1 }}),我的意思是从sessionFactory得到的会话将为null。
mvn install
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceOri" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EHCacheProvider</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.jdbc.batch_size">1024</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.enable_lazy_load_no_trans">true</prop>
<prop key="hibernate.jdbc.batch_size">50</prop>
<prop key="hibernate.order_inserts">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ClassA.hbm.xml</value>
<value>ClassB.hbm.xml</value>
<value>ClassC.hbm.xml</value>
</list>
</property>
</bean>
文件位于*.hbm.xml
,我在编译后检查了类路径,但没有找到任何内容。
有人可以帮忙提出任何建议吗?
感谢。
答案 0 :(得分:0)
我发现在我的类路径中有两个带有不同版本的hibernate-commons-annotations jar。
/Users/name/aa-o/target/aa-o-0.0.1-SNAPSHOT/doctor-o-0.0.1-SNAPSHOT/lib/hibernate-commons-annotations-5.0.0.Final.jar:/Users/name/aa-o/target/aa-o-0.0.1-SNAPSHOT/lib/hibernate-commons-annotations-3.5.6.Final.jar
在Eclipse中触发的运行中,hibernate-commons-annotations-5.0.0.Final.jar工作正常,我得到了日志
INFO [qtp1412752396-16] org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
但是,在shell脚本触发的运行中,选择了hibernate-commons-annotations-3.5.6.Final.jar并且系统失败。日志就像
INFO [qtp1412752396-16] org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {3.5.6.Final}