spring配置文件出错sssssssssssssssssss

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.testJob.pss.dao.EmployeeDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:438)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
... 58 more

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
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/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
default-autowire="byName" default-lazy-init="true">

<context:component-scan base-package="cn.testJob.pss" />

<!-- <bean class="cn.itproject.crm.controller.init.ApplicationInitListener"> -->
<!-- <property name="companyService" ref="companyServiceImpl"/> -->
<!-- <property name="configService" ref="configServiceImpl"/> -->
<!-- <property name="notificationService" ref="notificationServiceImpl"/> -->
<!-- </bean> -->

<bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:mysql.properties</value>
            <value>classpath:druid.properties</value>
            <value>classpath:hibernate.properties</value>
            <value>classpath:redis.properties</value>
        </list>
    </property>
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="druidDataSource" />
    <property name="packagesToScan">
        <list>
            <value>cn.testJob.pss.bean</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.use_sql_commants">${hibernate.use_sql_comments}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>

            <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
            <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
            <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.cache.provider_configuration_file_resource_path}
            </prop>
            <prop key="hibernate.cache.use_structured_entries">${hibernate.cache.use_structured_entries}</prop>
        </props>
    </property>
</bean>
<bean id="txManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>
<!-- <aop:aspectj-autoproxy proxy-target-class="true"/> -->
<aop:config>
    <aop:pointcut id="bizMethods"
        expression="execution(* cn.testJob.pss.service.*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>

<import resource="applicationContext-*.xml"/>

这个是sprin配置文件
init-method="init" destroy-method="close">
<!-- 数据库基本信息配置 -->




<!-- 初始化连接数量 -->

<!-- 最大并发连接数 -->

<!-- 最小空闲连接数 -->

<!-- 配置获取连接等待超时的时间 -->

<!-- 超过时间限制是否回收 -->

<!-- 超过时间限制多长删除 -->

<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->

<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->

<!-- 用来检测连接是否有效的sql,要求是一个查询语句 -->

<!-- 申请连接的时候检测 -->

<!-- 申请连接时执行validationQuery检测连接是否有效,配置为true会降低性能 -->

<!-- 归还连接时执行validationQuery检测连接是否有效,配置为true会降低性能 -->

<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->

value="${druid.maxPoolPreparedStatementPerConnectionSize}" />
<!--属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有: 监控统计用的filter:stat 日志用的filter:log4j 防御SQL注入的filter:wall -->

<!-- 输出可执行的SQL -->
<!-- 参考:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_LogFilter -->
<!-- 
    <bean id="log-filter" class="com.alibaba.druid.filter.logging.Log4jFilter">
        <property name="statementExecutableSqlLogEnable" value="true" />
    </bean>
 -->

<!-- 配置Spring监控 -->
<!-- 参考:https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_Druid%E5%92%8CSpring%E5%85%B3%E8%81%94%E7%9B%91%E6%8E%A7%E9%85%8D%E7%BD%AE -->
<bean id="druid-stat-interceptor"
    class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor">
</bean>

<bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut"
    scope="prototype">
    <property name="patterns">
        <list>
            <value>cn.testJob.pss.service.*</value>
            <value>cn.testJob.pss.dao.*</value>
        </list>
    </property>
</bean>
<aop:config>
    <aop:advisor advice-ref="druid-stat-interceptor"
        pointcut-ref="druid-stat-pointcut" />
</aop:config>
这个是数据源配置文件

麻烦了,各位大神,是在找不出哪里出问题了

sql

4个回答

是不是配置文件没有定义bean。。

EmployeeDao 的实现类找不到

Ro_bot
Ro_bot 回复qq_37788296: 最好将代码上传到 github 或者其它,只言片语看不出来病原,我只能说先解决第一个错误
2 年多之前 回复
qq_37788296
small和尚 回复qq_37788296: 配置文件都写了的,不只是employee没找到,其他的都找不到
2 年多之前 回复
qq_37788296
small和尚 就是,但问题出在哪里就是没看见
2 年多之前 回复

是不是实现类上没有加注解,spring扫描不到

没有定义bean,要么使用开启注解,要么定义bean

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!