我的构建使用码头在本地运行,但是当我尝试通过 tomcat6 在我的 aws 服务器上部署战争时,我收到以下错误。最初,我得到了无法创建 PoolableConnectionFactory,但我已经将我的 url 固定到了 db。不幸的是,除了下面的跟踪之外,我在详细日志中没有看到任何其他错误。还有什么问题?或者我还能尝试什么?任何想法表示赞赏!
错误 org.springframework.web.context.ContextLoader - 上下文初始化失败 org.springframework.beans.factory.UnsatisfiedDependencyException:创建 ServletContext 资源 [/WEB-INF/applicationContext.xml] 中定义的名称为“userManager”的 bean 时出错:表示不满足的依赖关系通过类型为 [UserDaoImpl] 的索引为 0 的构造函数参数::没有为依赖项找到类型为 [UserDaoImpl] 的匹配 bean:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注解:{}; 嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项找到类型为 [UserDaoImpl] 的匹配 bean:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注释:org.springframework.beans.factory.support 中的 {}。
更新
我在日志中发现了以下内容,想知道我创建 bean 的方式是否无法在服务器上正确处理:
org.springframework.web.context.support.XmlWebApplicationContext - Bean 'sessionFactory' 不符合被所有 BeanPostProcessors 处理的条件(例如:不符合自动代理的条件)
我的 applicationContext.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- to deal w/hibernate transaction types -->
<aop:config>
<aop:pointcut id="managerPC" expression="execution(* com.jmt.service..*Manager.*(..))"/>
<aop:advisor id="managerTx" advice-ref="txManagerAdvice" pointcut-ref="managerPC" order="10"/>
</aop:config>
<tx:advice id="txManagerAdvice">
<tx:attributes>
<tx:method name="save*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
<tx:method name="create*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
<tx:method name="add*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
<tx:method name="update*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
<tx:method name="import*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
<tx:method name="change*" isolation="READ_COMMITTED"/>
<tx:method name="copy*" isolation="READ_COMMITTED"/>
<tx:method name="remove*" isolation="READ_COMMITTED"/>
<tx:method name="delete*" isolation="READ_COMMITTED"/>
<tx:method name="send*" isolation="READ_COMMITTED"/>
<tx:method name="set*" propagation="NOT_SUPPORTED"/>
<tx:method name="batch*" propagation="NEVER"/>
<tx:method name="wipe*" propagation="NEVER"/>
<tx:method name="*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- end aop for hibernate transactions-->
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
<context:spring-configured/>
<context:component-scan base-package="com.jmt">
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean class="com.jmt.model.PinEntity"/>
<bean class="com.jmt.model.UserEntity"/>
<!--bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="poolPreparedStatements" value="true"/>
<property name="defaultAutoCommit" value="true"/>
<property name="maxActive" value="100"/>
<property name="maxIdle" value="30"/>
<property name="maxWait" value="1000"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="60"/>
<property name="logAbandoned" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="10000"/>
<property name="minEvictableIdleTimeMillis" value="60000"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
<prop key="hibernate.jdbc.batch_size">15</prop>
<prop key="hibernate.connection.isolation">2</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.jmt.model</value>
</list>
</property>
</bean>
<bean id="hibernateDaoSupport" abstract="true"
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="hibernateHelper" class="org.springframework.orm.hibernate3.HibernateTemplate" >
<constructor-arg ref="sessionFactory"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="hibernateManagedSession" value="true"/>
</bean>
<bean id="pinDao" class="com.jmt.hibernate.dao.PinDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="userDao" class="com.jmt.hibernate.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="pinManager" class="com.jmt.service.PinManagerImpl" autowire="byName" />
<bean id="userManager" class="com.jmt.service.UserManagerImpl" autowire="byName" />
<bean id="homeController" class="com.jmt.controller.HomeController" scope="prototype" autowire="byName" />
<bean id="mapCreationForm" class="com.jmt.controller.forms.MapCreationForm" scope="prototype" autowire="byName" />
</beans>
enter code here