SSH---Spring reduces the amount of configuration to abstract public configuration
Recent projects have encountered a problem with a special foundation for spring configuration-reducing the amount of configuration to abstract the public configuration. For this purpose to look at the previous video has been seen just like the demo, so borrow a share to everyone.
Abstract before
The configuration file is roughly the following (it is only possible to post the abstract place):
<bean id= "bean2" class= "com.tgb.spring.Bean2" > <property name= "id" value= "/> <propertyname=" NA Me "value=" Zhangsan "/> <propertyname=" Sex "value=" nan "/> </bean> <beanid=" bean3 "class=" com.t Gb.spring.Bean3 "> <propertyname=" id "value="/> <propertyname= "name" value= "Zhangsan"/> & Lt;propertyname= "Sex" value= "nan"/><property name= "age" > <value>90</value> </property& Gt <property name= "password" value= "123"/> </bean> <beanid= "Bean4" class= "Com.tgb.spring.Bean4" > <propertyname= "id" value= "/>" <propertyname= "name" value= "Zhangsan"/> <propertyname= "Sex" val Ue= "Nan"/> <propertyname= "age" > <value>90</value> </property> </bean> <bean id= "Bean5" class= "Com.tgb.spring.Bean5" > <property name= "password" value= "123"/> </bean& Gt
Abstract after
After the abstraction the configuration file looks much more comfortable, as follows:
<beanid= "bean2" class= "com.tgb.spring.Bean2" > <propertyname= "bean3" ref= "Bean3"/> <propertyname= "Bean4" > <refbean= "Bean4"/> </property> &l T;propertyname= "Bean5" ref= "Bean5"/> </bean> <bean id= "bean3" class= "Com.tgb.spring.Bean3" ; <property name= "id" value= "/> <property name=" name "value=" Zhangsan "/> <propert Y name= "Sex" value= "nan"/> </bean> <bean id= "Bean4" class= "Com.tgb.spring.Bean4" > <property name= "id" value= "/> <property name=" name "value=" Zhangsan "/> <pro Perty name= "Sex" value= "nan"/> <propertyname= "age" > <value>90</value> </property> </bean> <bean id= "Bean5" class= "Com.tgb.spring.Bean5" ><propertyname= "password" value= "123"/> </bean>
Summarize
In fact, it's quite simple. If we can pay more attention to some of these details when we write the code, we can make our code look more concise, on the other hand, I think whether it is written code not only can understand, but also to facilitate other people to review.
I would like to do every thing through their own hands, so that every one of the author to work at ease.
This article Resources link http://download.csdn.net/detail/senior_lee/9068837
Copyright NOTICE: This article for Bo Master original article, not by Bo Master permission to mention the link can be reproduced.
SSH---Spring reduces the amount of configuration to abstract public configuration