![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Spring
Prime0906
这个作者很懒,什么都没留下…
展开
-
Spring 高级装配
Spring 高级装配标签: Spring1.处理自动装配时的歧义性例子: 下面的代码通过注解的方式声明了三个组件分别实现接口Dessert,而setDessert()方法通过@Autowired自动装配。@Autowired public void setDessert(Dessert dessert) { this.dessert = dessert; }@Componenet pub原创 2017-08-17 10:38:02 · 271 阅读 · 0 评论 -
装配Bean
2.4 声明一个简单的Bean bean class="com.helloworld.HelloWorld"> bean> 因为没有给出ID,所以这个Bean将会根据全限定类名来进行命名。在这个例子中,ID为com.helloworld.HelloWorld#0,我们通过ID来引用Bean。因为是全限定类名,猜想Spring是通过反射来创建Bean的,所以我们的Bean需要有一原创 2017-08-18 20:10:36 · 206 阅读 · 0 评论 -
装配Bean(2)-通过注解配置Bean
组件扫描组件扫描(component scanning): Spring 能够从 classpath 下自动扫描, 侦测和实例化具有特定注解的组件. @Component: 基本注解, 标识了一个受 Spring 管理的组件 @Repository: 标识持久层组件 @Service: 标识服务层(业务层)组件 @Controller: 标识表现层组件 对于扫描到的组件, Spring 有默认的原创 2017-08-19 16:23:00 · 213 阅读 · 0 评论 -
Spring AOP
Spring AOP基于代理实现的日志栗子:一个计算器Calculator接口public interface Calculator { int add(int i, int j); int sub(int i, int j); }一个简单实现了该接口的类MyCalculatorpublic class MyCalculator implements Calculator {原创 2017-08-20 14:34:10 · 264 阅读 · 0 评论