Java SessionFactory可以';maven编译到jar后无法获得

Java SessionFactory可以';maven编译到jar后无法获得,java,spring,hibernate,maven,sessionfactory,Java,Spring,Hibernate,Maven,Sessionfactory,我使用的是与Spring集成的Hibernate,请查找下面的bean forSessionFactory,所有这些都在Eclipse中运行良好,但是,在编译到jar后无法获得SessionFactory(mvn install),我的意思是从SessionFactory获得的会话将为空 <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

我使用的是与Spring集成的Hibernate,请查找下面的bean for
SessionFactory
,所有这些都在Eclipse中运行良好,但是,在编译到jar后无法获得SessionFactory(
mvn install
),我的意思是从SessionFactory获得的会话将为空

<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>

org.hibernate.dialogue.mysqldialogue
假的
真的
org.hibernate.cache.EHCacheProvider
假的
假的
1024
真的
真的
50
真的
ClassA.hbm.xml
ClassB.hbm.xml
ClassC.hbm.xml
*.hbm.xml
文件位于
src/main/resources
中,编译后我检查了类路径,没有发现任何内容

有人能帮忙给点建议吗


谢谢。

我发现在我的类路径中有两个版本不同的hibernate commons注释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}

您可以附加错误日志、类和其他配置吗。什么是空的?另外,您没有
hibernate.cfg.xml
hibernate.properties
某个地方/@HarbeerKadian错误是从会话工厂获得的null会话导致的NullPointerException,实际上根本原因是会话工厂bean初始化失败。@M.Deinum hibernate我使用的是在spring中集成的,所以没有hibernate.cfg.xml和hibernate.properties。谢谢大家,我现在就解决这个问题。