首页新闻找找看学习计划

错误创建bean 'sessionFactory' and Cannot resolve reference to bean 'dataSource' bean property 'dataSource';

0
[待解决问题]

rg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\JAVAEE_Project1.metadata.plugins\org.eclipse.wst.server.core\tmp5\wtpwebapps\project\WEB-INF\classes\context\applicationContext-dataAccess.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean name 'txAdvice' in bean reference for bean property 'adviceBeanName'
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean name 'txAdvice' in bean reference for bean property 'adviceBeanName'
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean name 'txAdvice' in bean reference for bean property 'adviceBeanName'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:117)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:73)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:85)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:265)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:316)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:245)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:124)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:829)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:776)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5197)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5720)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

11月 22, 2019 5:26:28 下午 org.apache.catalina.core.StandardContext startInternal
严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
11月 22, 2019 5:26:28 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/pgkj_new] startup failed due to previous errors
11月 22, 2019 5:26:28 下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
11月 22, 2019 5:26:28 下午 org.apache.catalina.core.ApplicationContext log
信息: Shutting down Log4J
11月 22, 2019 5:26:28 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/pgkj_new] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
11月 22, 2019 5:26:28 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
11月 22, 2019 5:26:28 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
11月 22, 2019 5:26:28 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 4653 ms

问题补充:

<!-- A Local dataSource Definition using c3p0 connection pool -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${connection.driver_class}" />
<property name="jdbcUrl" value="${jdbc.connection.url}" />
<property name="idleConnectionTestPeriod" value="${jdbc.pool.c3p0.idle_connection_test_period}" />
<property name="preferredTestQuery" value="${jdbc.pool.c3p0.preferred_test_query}" />
<property name="maxIdleTime" value="${jdbc.pool.c3p0.max_idle_time}" />
<property name="properties">
<props>
<prop key="user">${jdbc.connection.username}</prop>
<prop key="password">${jdbc.connection.password}</prop>
<prop key="c3p0.acquire_increment">${jdbc.pool.c3p0.acquire_increment}</prop>
<prop key="c3p0.max_size">${jdbc.pool.c3p0.max_size}</prop>
<prop key="c3p0.min_size">${jdbc.pool.c3p0.min_size}</prop>
</props>
</property>
</bean>

<!-- Hibernate SessionFactory definition using exposed dataSource -->
<!-- hibernate.properties and hibernate.cfg.xml will be loaded on startup -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <!-- 常加的 -->
    <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
    <property name="mappingLocations">
        <list>       
            <!-- jbmp's hbm.xml -->
            <!--  <value>classpath*:/org/jbpm/**/*.hbm.xml</value>-->
            
            <!-- other hbm.xml -->
            <value>classpath*:/com/pgkj/entity/*.hbm.xml</value>    
            <value>classpath*:/com/pgkj/entity2/*.hbm.xml</value>   
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
            <prop key="show_sql">true</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>

            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
        </props>
    </property>
</bean>

<!-- Transaction manager for a single JDBC DataSource -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>


<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
-->

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="tx*" propagation="REQUIRED" />
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="update*" propagation="REQUIRED" />
        <tx:method name="find*,get*,load*" propagation="REQUIRED"/>
        <!-- other methods are set to read only -->
        <tx:method name="*" propagation="SUPPORTS"/>
    </tx:attributes>
</tx:advice>

<!-- ensure that the above transactional advice runs for any execution   
    
    // execution(* com.pgkj.rocket.usermanager.logic.*Service.tx*(..))
    of an operation defined by specified interface //-->
<aop:config>
    <aop:pointcut id="allServiceMethods"
        expression="execution(* com.pgkj..*Service.*(..))" />
    <aop:advisor advice-ref="txAdvice"
        pointcut-ref="allServiceMethods" />
</aop:config>

</beans>

ipkhyq的主页 ipkhyq | 初学一级 | 园豆:124
提问于:2019-11-22 17:46
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册