Spring过滤器组件自动扫描
DAO 层
package com.yiibai.customer.dao;public class CustomerDAO
{@Overridepublic String toString() {return "Hello , This is CustomerDAO";}
}
Service 层
package com.yiibai.customer.services;import org.springframework.beans.factory.annotation.Autowired;
import com.yiibai.customer.dao.CustomerDAO;public class CustomerService
{@AutowiredCustomerDAO customerDAO;@Overridepublic String toString() {return "CustomerService [customerDAO=" + customerDAO + "]";}}
Spring 过滤
<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/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd"><context:component-scan base-package="com.yiibai" ><context:include-filter type="regex" expression="com.yiibai.customer.dao.*DAO.*" /><context:include-filter type="regex" expression="com.yiibai.customer.services.*Service.*" /></context:component-scan></beans>
执行
package com.yiibai.common;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import com.yiibai.customer.services.CustomerService;public class App
{public static void main( String[] args ){ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"Spring-AutoScan.xml"});CustomerService cust = (CustomerService)context.getBean("customerService");System.out.println(cust);}
}
输出
CustomerService [customerDAO=Hello , This is CustomerDAO]
<context:component-scan base-package="com.yiibai.customer" ><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /> </context:component-scan>
<context:component-scan base-package="com.yiibai" ><context:exclude-filter type="regex" expression="com.yiibai.customer.dao.*DAO.*" /> </context:component-scan>
Spring过滤器组件自动扫描相关推荐
- Spring Aop 组件概述
Spring Aop 概述 AOP(Aspect-Oriented Programming) 面向切面编程, 这种编程模型是在 OOP(Object-Oriented Programming) 的基础 ...
- spring 组件扫描_避免不必要的Spring配置组件扫描
spring 组件扫描 我在堆栈溢出中遇到了一个有趣的问题. Brett Ryan有问题,Spring Security配置被初始化了两次. 当我查看他的代码时,我发现了问题所在. 让我展示显示代码. ...
- 避免不必要的Spring配置组件扫描
我在堆栈溢出中遇到了一个有趣的问题. Brett Ryan有问题,Spring Security配置被初始化了两次. 当我查看他的代码时,我发现了问题所在. 让我展示显示代码. 他有相当标准的Spri ...
- spring过滤器Filter 、 拦截器Interceptor 、 切片Aspect 详解
springboot 过滤器Filter vs 拦截器Interceptor vs 切片Aspect 详解 1 前言 最近接触到了过滤器和拦截器,网上查了查资料,这里记录一下,这篇文章就来仔细剖析下过 ...
- spring aop组件_安全性中的Spring AOP –通过方面控制UI组件的创建
spring aop组件 以下文章将显示在我参与的一个项目中,我们如何使用Spring的AOP来介绍一些与安全性相关的功能. 这样的概念是,为了使用户能够看到某些UI组件,他需要具有一定级别的安全特权 ...
- 分布式锁 动态代理 Java数据结构List,Set,Map,Spring执行流程,Spring MVC组件
这里对今日的内容进行总结: 分布式锁具备的条件: 具备的条件: 在分布式系统环境下,一个方法在同一时间只能被一个机器的一个线程执行. 高可用的获取锁与释放锁. 高性能的获取锁与释放锁. 具备可重入的特 ...
- spring boot组件_Spring Boot Framework的关键组件和内部
spring boot组件 In my previous post "Introduction to Spring Boot", we have discussed about S ...
- java敏感词过滤器组件
简介:用java写过滤器组件,需求:这里可以☆赌☆博☆,可以☆嫖☆娼☆,可以☆吸☆毒☆,可以☆开☆票☆,哈哈哈!经过过滤器过滤后变为这里可以☆*☆,可以☆***☆,可以☆***☆,可以☆*☆,哈哈哈! ...
- Spring 条件组件注解:`@Conditional` 与 `@ConditionalOnBean`
Spring 条件组件注解:@Conditional 与 @ConditionalOnBean 文章目录 Spring 条件组件注解:`@Conditional` 与 `@ConditionalOnB ...
最新文章
- 陌陌安全开源了 Java 静态代码安全审计插件
- 智办事协同办公:数字化转型下的高效工作方式
- 24.两两交换链表中的结点
- 不一样的随机数生成方法(C/C++)
- mysql事务实战_MySQL - 实战 (2) - 事务隔离
- MFC 自定义消息四步曲与在参数中传递变量
- php枚举mysql,小技巧:取得MYSQL中ENUM(枚举)列的全部可能值。-PHP教程,PHP应用...
- 一进庙会freeeim
- 使用Notepad++正则提取数据,然后进行替换
- FusionChart 保存图片
- 于仕琪老师的人脸检测库
- 代理ip,代理服务器等相关
- 如何利用Python对服务器的接口进行压力测试
- Apache ShenYu源码阅读系列-Dubbo插件
- 计算机网络长度,以太网中mtu默认长度 你应该知道的计算机网络知识(2)
- Artifact “xxx - xxxx“:war exploded: 部署工件时出错。请参阅服务器日志了解详细
- hutool工具类生成二维码案例
- 计算机开机无法进入桌面,电脑开机不能进入系统界面的故障修复
- 最常见的卸载Mac应用软件方法,彻底清除,果断收藏!
- (11)EKF - (3) EKF3匹配度和Lane切换
热门文章
- Qt Creator建立多个平台
- Qt Creator从Maya导出3D资产
- 有序数组中查找数字的范围
- c++多态相关面试题
- C语言中时间的基本用法
- C语言fstat函数获取文件的大小
- mysql 优化 类型_MySQL数据类型的优化选择
- 10_InfluxDB常用函数(三)变换类函数(DERIVATIVE, DIFFERENCE,ELAPSED,MOVING_AVERAGE,NON_NEGATIVE_DERIVATIVE)等
- 53_Auto-Encoders和Variational AutoEncoders(VAE)、PCA降维和Auto-Encoders降维的比较、Auto-Encoders变种、pytorch实现等
- 数据库元数据数据字典查询_9_列出给定表的所有约束