Spring (依赖注入)
来源:互联网 发布:windows图标 编辑:程序博客网 时间:2024/05/05 20:36
下面是配置文件,配置了spring的扫描路径,不配置这个注解不起作用。
这是一个接口:
下面声明一个简单的类,继承了上面的借口:
下面是测试代码:
freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面、建表sql脚本,处理类,service等完整模块
B 集成阿里巴巴数据库连接池druid;
数据库连接池 阿里巴巴的 druid。Druid在监控、可扩展性、稳定性和性能方面都有明显的优势
C集成安全权限框架shiro ;
Shiro 是一个用 Java 语言实现的框架,通过一个简单易用的 API 提供身份验证和授权,更安全,更可靠
D 集成ehcache 分布式缓存 ;
是一个纯Java的进程内缓存框架,具有快速、精干等特点,广泛使用的开源Java分布式缓存。
E 集成微信接口开发; F 图片爬虫技术; G SQL 编辑器, 支持复杂sql语句,生成报表,可以导出excel;
H websocket及时通讯技术;(即时聊天、及时站内信并声音提醒、实时在线管理、websocket及时刷新页面);
- package com.expect.oa.config;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.Configuration;
- @Configuration
- @ComponentScan("com.expect.oa.*")
- //@ComponentScan(basePackages={"com.expect.oa.DI.*","com.expect.oa.DI2.*"})
- //多个包可以这样写,这相当于在XML里配置了自动扫描
- public class SpringConfig {
- }
这是一个接口:
- package com.expect.oa.DI.interfaces;
- public interface InterA {
- void action1 ();
- }
下面声明一个简单的类,继承了上面的借口:
- package com.expect.oa.DI;
- import org.springframework.stereotype.Component;
- import com.expect.oa.DI.interfaces.InterA;
- @Component("interAImpl")
- //@Named("interAImpl")同样的效果
- public class CompA implements InterA{
- @Override
- public void action1() {
- // TODO Auto-generated method stub
- System.out.println("spring DI");
- }
- }
下面是测试代码:
- package com.expect.oa.test;
- import javax.annotation.Resource;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.test.context.ContextConfiguration;
- import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
- import com.expect.oa.DI.interfaces.InterA;
- import com.expect.oa.config.SpringConfig;
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(classes = {SpringConfig.class})
- public class TestSpringDI {
- //个人建议给每个组件都起名。
- @Resource(name="interAImpl")
- //@Autowired 同样的效果
- InterA aService;
- //这里是测试依赖注入
- @Test
- public void testDI() {
- aService.action1();
- }
- }
获取【下载地址】 【免费支持更新】
三大数据库mysql oracle sqlsever 更专业、更强悍、适合不同用户群体
【新录针对本系统的视频教程,手把手教开发一个模块,快速掌握本系统】
A 集成代码生成器 [开发利器)+快速构建表单;三大数据库mysql oracle sqlsever 更专业、更强悍、适合不同用户群体
【新录针对本系统的视频教程,手把手教开发一个模块,快速掌握本系统】
freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面、建表sql脚本,处理类,service等完整模块
B 集成阿里巴巴数据库连接池druid;
数据库连接池 阿里巴巴的 druid。Druid在监控、可扩展性、稳定性和性能方面都有明显的优势
C集成安全权限框架shiro ;
Shiro 是一个用 Java 语言实现的框架,通过一个简单易用的 API 提供身份验证和授权,更安全,更可靠
D 集成ehcache 分布式缓存 ;
是一个纯Java的进程内缓存框架,具有快速、精干等特点,广泛使用的开源Java分布式缓存。
E 集成微信接口开发; F 图片爬虫技术; G SQL 编辑器, 支持复杂sql语句,生成报表,可以导出excel;
H websocket及时通讯技术;(即时聊天、及时站内信并声音提醒、实时在线管理、websocket及时刷新页面);
0 0
- Spring依赖注入:注解注入
- spring 的依赖注入
- Spring依赖注入实践经验
- Spring的依赖注入
- Spring依赖注入
- spring(依赖注入-DI)
- spring依赖注入
- spring依赖注入
- 白话spring依赖注入
- Spring依赖注入方式
- Spring的依赖注入
- Spring依赖注入
- Spring依赖注入方式
- Spring 依赖注入
- spring依赖注入方式
- spring的依赖注入
- Spring依赖注入方式
- Spring依赖注入方式:
- easyui combotree选项重复
- TCP协议的send与recv以及链接的阻塞与关闭问题
- SpriteKit塔防游戏动态改变防御塔价格标签的颜色
- java集合学习
- 用Editplus配置JAVA编辑环境
- Spring (依赖注入)
- 白书练习之子集生成
- Dagger2
- Spring MVC组件-HandleMapping处理器映射
- framework层,屏幕旋转90度
- CSS篇——如何利用css让元素到另一个元素的后面
- Oracle Sequence自动补全指定位数
- 今年以后Web前端的发展趋势在哪里?
- html5 video 那些事