春豆错误 [英] Error with spring bean

查看:22
本文介绍了春豆错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:添加 Maven 依赖*更新:通过添加 maven 依赖解决了这个错误 *

美好的一天.我有 AplicationContext.xml 的这部分

Good day. I have this part of AplicationContext.xml

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="namingStrategy">
        <ref bean="namingStrategy"/>
    </property>
    <property name="mappingResources">
        <list>
            <!--<value>genericdaotest/domain/Person.hbm.xml</value>-->
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property>
    <property name="dataSource">
        <ref bean="dataSource"/>
    </property>
</bean>

Maven dep for spring 和 hibernate

Maven dep for spring and hibernate

  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>2.0.6</version>
        </dependency>


      <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.2.Final</version>
        </dependency>

但是,当我启动我的应用程序时,它告诉我这个错误

But, when I start my Application, it said me this error

Cannot find class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.LocalSessionFactoryBean

但我使用的是 hibernate4.它有什么样的魔力?=)我已经尝试重新部署应用程序,但结果是一样的

But I am using hibernate4. What kind of magic does it? =) I have already tried to redeploy app, but result is the same

推荐答案

你错过了 Spring-ORM 模块:

You have missed the Spring-ORM module:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>

检查包列表,它包含org.springframework.orm.hibernate3 包和你需要的类.

Check the packages list, it contains the org.springframework.orm.hibernate3 package and the class you need.

另外,我觉得类不对,不应该是hibernate4.LocalSessionFactoryBean吗?你在使用注解吗?还是 XML?

Also, I think the class is wrong, shouldn't it be the hibernate4.LocalSessionFactoryBean? Are you using annotations? or XML?

这篇关于春豆错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆