springframework:创建名为'userService'的bean时出错:

时间:2017-04-26 15:38:38

标签: java spring hibernate maven spring-mvc

我有一个maven项目,其中集成了spring框架,我使用此项目为移动应用程序构建Web服务。当我在AWS ubuntu服务器上部署BeanCreationException并且无法在tomcat7上运行时,该项目会给出BeanCreationException。当我在当地环境中运行它时工作正常。下面是tomcat7的错误日志。

WARN [localhost-startStop-1] DirectoryProviderHelper.makeSanityCheckedDirectory(258) | HSEARCH000041: Index directory not found, creating: '/usr/share/tomcat7/baseapp-1.0/index'
ERROR [localhost-startStop-1] ContextLoader.initWebApplicationContext(318) | 
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Cannot resolve reference to bean 'userManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.washkart.www.service.impl.UserManagerImpl.setUserDao(com.washkart.www.dao.UserDao); nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager com.washkart.www.model.User

我的hibernate.cfg看起来像这样:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
    <mapping class="com.washkart.www.model.User"/>
    <mapping class="com.washkart.www.model.Role"/>
    <mapping class="com.washkart.www.model.WashUser"/>
    <mapping class="com.washkart.www.model.WashOrder"/>
    <mapping class="com.washkart.www.model.Service"/>
    <mapping class="com.washkart.www.model.Item"/>
    <mapping class="com.washkart.www.model.Device"/>
    <mapping class="com.washkart.www.model.Offer"/>
    <mapping class="com.washkart.www.model.Employee"/>
    <mapping class="com.washkart.www.model.Attendance"/>

    <mapping class="com.washkart.www.model.Rates"/>
</session-factory>
</hibernate-configuration>

applicationContext-dao.xml是:

<?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"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
   default-lazy-init="true">

<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" destroy-method="destroy">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
            <!-- Hibernate Search index directory -->
            <prop key="hibernate.search.default.indexBase">${app.search.index.basedir}</prop>
        </props>
        <!-- Turn batching off for better error messages under PostgreSQL -->
        <!-- hibernate.jdbc.batch_size=0 -->
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!-- Activates scanning of @Autowired -->
<context:annotation-config/>

<!-- Activates scanning of @Repository -->
<context:component-scan base-package="com.washkart.www.dao"/>

</beans>

该项目在其中一台旧AWS服务器上正常运行但在新服务器上崩溃。我对Spring安全框架很新,并且对此并不了解。基础项目集成了弹簧安全性。

帮我解决错误。

TIA

0 个答案:

没有答案