创建名称为' sessionFactory'的bean时出错在ServletContext资源中定义。需要解决方案

时间:2018-02-23 13:13:25

标签: mysql spring hibernate maven model-view-controller

这是错误

  

23-Feb-2018 17:14:17.569 INFO [RMI TCP连接(4)-127.0.0.1]   org.apache.catalina.core.ApplicationContext.log没有Spring   在classpath 23-Feb-2018上检测到的WebApplicationInitializer类型   17:14:17.783 INFO [RMI TCP连接(4)-127.0.0.1]   org.apache.catalina.core.ApplicationContext.log初始化Spring   root WebApplicationContext 23-Feb-2018 17:14:19.361严重[RMI TCP   (4)连接-127.0.0.1]   org.apache.catalina.core.StandardContext.listenerStart异常   将上下文初始化事件发送到类的侦听器实例   [org.springframework.web.context.ContextLoaderListener]   org.springframework.beans.factory.BeanCreationException:错误   创建名为' sessionFactory'的bean在ServletContext中定义   resource [/WEB-INF/applicationContext.xml]:调用init方法   失败;嵌套异常是java.lang.NoClassDefFoundError:   的javax / XML /结合/ JAXBException

的applicationContext.xml

http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="configLocation" value="WEB-INF/hibernate.cfg.xml" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/lpg</prop>
            <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
            <prop key="hibernate.connection.username">root</prop>
            <prop key="hibernate.connection.password"></prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <!--prop key="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="javax.persistence.validation.mode">none</prop>
            <prop key="hibernate.c3p0.min_size">5</prop>
            <prop key="hibernate.c3p0.max_size">20</prop>
            <prop key="hibernate.c3p0.timeout">300</prop>
            <prop key="hibernate.c3p0.max_statements">50</prop>
            <prop key="hibernate.c3p0.idle_test_period">3000</prop-->
        </props>
    </property>
    <!--property name="annotatedClasses">
        <list>
            <value>com.all.packages.model.City</value>
            <value>com.all.packages.model.Country</value>
            <value>com.all.packages.model.District</value>
            <value>com.all.packages.model.State</value>
        </list>
    </property-->
    <!--property name="hibernateProperties">
        <props>
            <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/crm</prop>
            <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
        </props>
    </property-->
</bean>

<!-- Spring Email Sender Bean Configuration -->

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">

    <!--property name="host" value="smtp.mail.yahoo.com" />
    <property name="port" value="587" />
    <property name="username" value="" />
    <property name="password" value="" /-->
    <property name="host" value="smtp.gmail.com"/>
    <property name="port" value="25"/>
    <property name="username" value="jyotirmoy.saha@gmail.com"/>
    <property name="password" value="prodsoftpakak2007"/>

    <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.debug">true</prop>
            <prop key="mail.transport.protocol">smtp</prop>
            <prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
            <prop key="mail.smtp.socketFactory.port">465</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
        </props>
    </property>

</bean>

<!-- Spring Email Attachment Configuration -->

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

    <!-- Maximum Upload Size In Bytes -->
    <property name="maxUploadSize" value="20971520" />
    <!-- Maximum Size Of File In Memory (In Bytes) -->
    <property name="maxInMemorySize" value="1048576" />

</bean>


<tx:annotation-driven />
<bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="persistenceExceptionTranslationPostProcessor"
      class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

错误在哪里请帮忙。我正在使用Intellij Idea

0 个答案:

没有答案