spring frame injection xml configuration file attributes for the entity class of complex

  spring framework is a framework javaWeb vital project, most of the web project is divided into persistence layer, service layer on the working level, the control layer. Persistence layer (dao, mapper) connect to a database, to complete the project and transfer data in the database; service layer (-Service) mainly to complete the project various operations (add, delete, change,), connected persistence layer, control layer, and also to deal with various entities classes, and the control layer is mainly dealing with web front page, and the page data is transmitted. Today, we focus on the core service layer framework spring framework, as well as various integration framework. Introduces a little knowledge in the spring, it is difficult to remember that in the framework of the entity properties spring DI (injection), which is the assignment, the entity class complex data types, such as arrays, map collection, set collection, , List of injection method.

  First, create an entity class, setter, getter method to go wave

 

 

  The entity class defines various types of attribute


 

 

 

   Write to bean tag in your configuration files in xml, id is a unique identifier to be used by id use, class to class path entity, the entity selected by the class attribute name tag property in the name of the property, where by get method get

Set in the array by a plurality of property value array values


 

 

 

    This type of data is injected List, List of tag array, value is the value


 

 

   Set data injection, list tag


 

 

   Map data injection type, props tag


 

 

   Properties injection type data, map label


  These are the types of these complex injection method, you can see, these data types of tags are mutually hell broke loose, do not know who invented this thing, this thing is no one to remember, when used directly check if the line .

  If the matter sorted out this article to bring you help, it would be so honored, this is my first post post, the future will record some of their own problems and solutions in the study, are welcome to learn from each other, interact with each other.

 

Guess you like

Origin www.cnblogs.com/blogofbin/p/11574096.html