maven编译成jar后获取不到SessionFactory

SessionFactory can't be got after compiling to jar by maven

我正在使用与Spring集成的Hibernate,请为SessionFactory找到下面的bean,在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>

*.hbm.xml个文件在src/main/resources里,编译后查了classpath,没找到

谁能帮忙给点建议吗?

谢谢。

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