In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
In this issue, the editor will bring you about how the p tag and c tag in Spring are injected. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Spring p and c tag injection mode 1. Write the entity class package com.ming04.pojo;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;@Data@AllArgsConstructor@NoArgsConstructorpublic class User {private int id; private String name;} 2. Configuration file (key) 3. Test @ Test public void Text () {ApplicationContext context = new ClassPathXmlApplicationContext ("Beans04.xml"); User user = (User) context.getBean ("user2"); System.out.println (user);} spring Bean injection and P tag using 1. Construction method parameters
Corresponding profile element
Can index | name | type one or three choose two; ref | value choose one of the two
2.setter method injection (recommended for development)
Provides a setter method for injecting attributes
Configure each injection attribute, corresponding to the element
3.p use of namespaces
After spring2.5, in order to simplify setter method attribute injection and refer to the concept of p namespace, child elements can be simplified to element attribute configuration!
a.
Introduce p namespace in applicationContext.xml
b. Simplify the configuration of injection
4. Property injection of collection type (understand)
Spring provides individual elements for each commonly used collection object to complete injection
List object-element
Set object-element
Map object-element
Properties object-element
The injection of collection properties is mainly used for the configuration of the framework!
This is how the p tag and c tag are injected into the Spring shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 237
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.