不可见类有抽象父类,spring配置子类bean,注入父类,aop就可以切父类的方法
public class TestBeanChild {
int b = 1; public TestBean createDefault() {
return new TestBeanDefault();
}
}
class TestBeanDefault extends TestBean{
int b=2;
}
包外面不能访问类TestBeanDefault
public abstract class TestBean {
private int a =0;
public void doBean(){
System.out.println("1321");
}
}
<bean id="a" class="com.yundaex.wms.config.TestBeanChild" />
<bean id="b" class="com.yundaex.wms.config.TestBeanChild" factory-bean="a" factory-method="createDefault" /> <aop:config proxy-target-class="true">
<aop:aspect ref="ifmAspect">
<aop:pointcut id="ifmAspectPointcut"
expression="execution( * com.yundaex.wms.config.TestBean.*(..))
"/>
<aop:around method="aroundMethod" pointcut-ref="ifmAspectPointcut"/>
</aop:aspect>
</aop:config>
@Autowired
private TestBean dd;
dd为父类实例其实是子类的cglib的代理对象
不可见类有抽象父类,spring配置子类bean,注入父类,aop就可以切父类的方法的更多相关文章
- spring中bean配置和bean注入
1 bean与spring容器的关系 Bean配置信息定义了Bean的实现及依赖关系,Spring容器根据各种形式的Bean配置信息在容器内部建立Bean定义注册表,然后根据注册表加载.实例化Bean ...
- JavaEE开发之Spring中的依赖注入与AOP
上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...
- JavaEE开发之Spring中的依赖注入与AOP编程
上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...
- Spring中给Bean注入集合
Spring中如果一个Bean里含有集合元素,需要给Bean里的集合元素注入元素时,可以采用如下方法,一个是构造器注入,一个是setter注入 JavaBean源代码: import java.uti ...
- Spring配置中<bean>的id和name属性
在BeanFactory的配置中,<bean>是我们最常见的配置项,它有两个最常见的属性,即id和name,最近研究了一下,发现这两个属性还挺好玩的,特整理出来和大家一起分享. 1.id属 ...
- Spring配置及依赖注入
入门 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-we ...
- c++ 的父类 new 重载, 子类new 对象的时候会调用父类的operater new
子类在new 对象的 时候 父类的new 进行了重载,那么会调用父类的operater new() 函数 #include <iostream> #include <string& ...
- Spring实战——无需一行xml配置实现自动化注入
已经想不起来上一次买技术相关的书是什么时候了,一直以来都习惯性的下载一份电子档看看.显然,如果不是基于强烈的需求或强大的动力鞭策下,大部分的书籍也都只是蜻蜓点水,浮光掠影. 就像有位同事说的一样,有些 ...
- 怎么随时获取Spring的上下文ApplicaitonContext,和Spring管理的Bean
BeanFactory接口 Interface BeanFactory getBean <T> T getBean(String name, Class<T> required ...
随机推荐
- matplotlib中文显示-微软雅黑
网上有很多方法,但是基本的是片面的. 参考1 https://tracholar.github.io/wiki/python/matplotlib-chinese-font.html 参考2 http ...
- 在node.js中建立你的第一个HTTp服务器
这一章节我们将从初学者的角度介绍如何建立一个简单的node.js HTTP 服务器 创建myFirstHTTPServer.js //Lets require/import the HTTP modu ...
- IoC~MVC3+EF+Autofac实现松耦合的系统架构
MVC3+EF+Autofac网上这种文章确实没有,呵呵,今天就写一个,代大家分享! 这个系列的文章将带我们进入一种新的开发模式,注入开发模式,或者叫它IOC模式,说起IOC你可以这样去理解它,它为你 ...
- listen and translation exercise 53
It was hard work and there weren't any interesting things for him. You should be an expert with comp ...
- python web server gateway interface (wsgi ) notes
前言: 注:如果需要得到支持批Python3.x以及包含了勘误表,附录,和说明的更新版规范,请查看PEP 3333 摘要: 这篇文档详细说明了一套在web服务器与Python web应用程序(web框 ...
- 【Lintcode】382.Triangle Count
题目: Given an array of integers, how many three numbers can be found in the array, so that we can bui ...
- echarts图表自适应
当页面上只引入一个图表 window.onresize= () =>{ myEchart.resize() } 当引入多个时,上面的方法只会影响最后一个图表 window.addEventLis ...
- 监测GPU使用情况命令
每2秒监测一次:watch -n 2 nvidia-smi
- 更换mysql数据目录后出现 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法
服务器上的mysql默认数据目录为/var/lib/mysql/,同时服务器的/空间不是很大,而近期又有大量的日志需要导入进行分析,时常搞得/的空间捉襟见肘,晚上一狠心就想把mysql的数据目录转移到 ...
- AD 学习
http://blog.csdn.net/lingpaoershiyishiji/article/details/9139527