zoukankan      html  css  js  c++  java
  • spring context:component-scan ex

    本意扫描除controller以外的bean,但启动时,包没有相应的Service bean,启动报错Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jwSkuService' is defined

    <context:component-scan base-package="com.jw.store" use-default-filters="false">
            <context:exclude-filter type="annotation"
                expression="org.springframework.stereotype.Controller" />
        </context:component-scan>

    尝试了很久,发现是use-default-filters="false"的原因, use-default-filters默认为true,会扫描controller、service、Component,

    如果需要指定只扫描某种bean, 配use-default-filters="false"  加 include-filter,如果需要排查某种bean   use-default-filters应该使用默认值true,进而使用exclude-filter进行排除

  • 相关阅读:
    LNMP架构三
    LNMP架构二
    LNMP架构
    LAMP架构三
    LAMP架构二
    LAMP架构
    rsync工具介绍
    mysqldump备份单表数据
    阿铭每日一题 day 14 20180125
    阿铭每日一题 day 13 20180124
  • 原文地址:https://www.cnblogs.com/chenge-0401/p/8618207.html
Copyright © 2011-2022 走看看