SSH---Spring reduces the amount of configuration to abstract public configuration

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.