【Spring In Action】Section 3 高级装配
来源:互联网 发布:万方数据库 编辑:程序博客网 时间:2024/06/05 21:06
- Spring Profile
- 条件化的bean声明
- 自动装配与歧义性
- bean的作用域
- Spring的语言表达式
一、环境与Profile
为了区分环境,引入了profile bean;
首先定义一个类:
@Configuration相当于XML中的Beans,@Bean相当于XML中的Bean
@Configuration@Profile("dev")public class DevelopmentProfileConfig{ @Bean public DataSource dataSource(){
return new XXXXXBuildr()
.setType()
.setUserName()
.setpassword()
.build();
}}
在XMl中也是可以进行对应的配置的:
<beans profile="dev"> <bean> </beans></beans><beans profile="prod"> <bean> </beans></beans>
那么问题来了,我们应该怎么样去激活某个profile呢?
其实这需要两个独立的属性:spring.profile.active和spring.profile.default
如下的几个途径可以设置哦:
- 作为DispatcherServlet的初始化参数;
- 作为web应用的上下文参数;
- 作为JNDI条目
- 作为环境变量
- 作为JVM的系统属性
- 在集成测试类上,可以使用@ActiveProfile注解设置
阅读全文
0 0
- 【Spring In Action】Section 3 高级装配
- Spring In Action 02 ---高级装配
- spring in action笔记(四)——高级装配
- spring in action-装配Bean
- spring(3)高级装配
- Spring In Action 01 ---装配Bean
- 【Spring】【笔记】《Spring In Action》第二章 Bean装配
- Spring in Action 学习笔记—第二章装配Bean
- Spring in Action入门之装配管理Bean
- Spring in action 01 -- 装配 Bean(@Autowired)
- Spring in action 03 -- 装配 Bean(xml配置)
- 《Spring In Action》 读书笔记(1) -- bean装配
- 《Spring In Action》 读书笔记(2) -- bean装配
- Spring in Action(第二章 装配 Bean)学习笔记
- Spring In Action学习笔记:Bean的简单装配
- Spring In Action(一):基于注解装配bean
- Spring In Action(二):基于XML配置装配bean
- spring in action 学习笔记(八)自动装配
- nfs: server 192.168.6.102 not responding, still trying 挂载问题
- 优先队列的应用
- 使用Curator实现多台机器中只有一台机器执行任务
- Coursera Algorithms week1 练习测验1:Social network connectivity
- Java导入、导出Excel
- 【Spring In Action】Section 3 高级装配
- 深机笔记
- python19difflib模块
- hdu 1232 畅通工程(并查集)
- Linux 4种互斥锁
- JDBC数据库mysql
- Random的nextInt用法
- Ubuntu16.0下codeblocks配置opencv2
- HDU 1892 See you~(二维树状数组的单点更新,区间求值)