Spring部署错误

时间:2016-08-31 16:12:49

标签: spring hibernate tomcat

org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalArgumentException: URL must not be null
SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

关于我在Spring 4上工作的项目,hibernate 4和apache tomcat 8.0.3.0,请帮忙解决这个问题。

更新了应用程序上下文:

<?xml version='1.0' encoding='UTF-8' ?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

     <!--scan the given package for repository--> 
    <context:component-scan base-package="com.persondata.dao"/> 
    <context:component-scan base-package="com.persondata.daoimpl"/> 

    <bean id="transactionManager"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager" 
          p:sessionFactory-ref="sessionFactory">
    </bean>

     <!--tx annotation driven scans registered spring beans for @Transactional-->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <!--support for @Controller and @RequestMapping-->
    <mvc:annotation-driven/>
    <!--support for general annotations such as @Required, @Autowired, @PostConstruct, and so on.-->
    <context:annotation-config/>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/persondata" /> 
                <property name="username" value="root" />
        <property name="password" value=""/> 
        <property name="connection.characterEncoding" value = "utf-8"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan" value="com.persondata.entity"/>
        <property name="hibernateProperties">
            <props>
                <prop key="c3p0.minPoolSize">15</prop>
                <prop key="c3p0.maxPoolSize">1000</prop>
                <prop key="c3p0.timeout">5000</prop>
                <prop key="c3p0.max_statement">500</prop>
                <prop key="c3p0.testConnectionOnCheckout">true</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean> 
</beans>

非常感谢你的帮助。我解决了这个问题,我提供了错误的数据源属性(用户名和密码)。

0 个答案:

没有答案