当前位置:网站首页>Internship: unfamiliar annotations involved in the project code and their functions
Internship: unfamiliar annotations involved in the project code and their functions
2022-07-06 01:24:00 【ahyo】
It is suggested that internship friends can record their internship process —— What have you learned every day What did you do , Write more in the process of learning demo.
Lombok in @EqualsAndHashCode Use of annotations :
Main test cases It is a subclass that inherits the parent class The two object properties of the instantiated subclass are set to the same value utilize equals Compare , But the result is true, Every instantiated object has a hashcode, This is the basis for comparison .
public class demo {
public static void main(String[] args) {
son y1=new son();
y1.setAge(10);
y1.setPrice(1000000);
y1.setName("asa");
son y2=new son();
y2.setAge(10);
y2.setPrice(1000000);
y2.setName("sdd");
System.out.println(" Object comparison "+y1.equals(y2));
}
}
@EqualsAndHashCode(callSuper = true), It is generated with its own attributes and attributes inherited from the parent class hashcode;
@EqualsAndHashCode(callSuper = false), Is to use only their own attributes to generate hashcode;
@Data amount to @Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode this 5 A collection of notes , and @EqualsAndHashCode The default is false.
So the corresponding solution —— Often add comments at the beginning of a class @Data perhaps @EqualsAndHashCode(callSuper=true)
@EqualsAndHashCode Mainly automatic model Class equals Methods and HashCode Method
It is worth mentioning that ——Model It's just for data transmission , It doesn't address services .ModelAndView But it can be used for business addressing , Is to set the corresponding static file to be requested , The static file here refers to something like jsp The file of
ValueOperations It's easy to operate value for example String Tool class The object of operation is redis database
A class with @Service annotation , Will be automatically registered to Spring Containers , No need to be in applicationContext.xml Defined in the configuration file bean 了 , Similar ones include @Component、@Repository、@Controller. This is why the class header is added @Service The following attributes or methods are direct @Resource perhaps @Autowired
about @Autowired The understanding of the I know a little better before :
1、 Generally, an interface class has only one implementation class Whether it is assembled by type or name, there is no problem
2、 If an interface class has multiple implementation classes Then the attribute name should be consistent with the component name , The component name can be specified at the time of declaration , such as @Service(“”), The attribute name is inconsistent with the component name , coordination @Qualifier The annotation specifies the component name .
Then there is what was involved before api Common comments
@TableField This kind of annotation involves the establishment of entity classes in database tables
边栏推荐
- Leetcode1961. 检查字符串是否为数组前缀
- Obstacle detection
- leetcode刷题_反转字符串中的元音字母
- [le plus complet du réseau] | interprétation complète de MySQL explicite
- ctf. Show PHP feature (89~110)
- ORA-00030
- Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
- Pbootcms plug-in automatically collects fake original free plug-ins
- Condition and AQS principle
- 3D模型格式汇总
猜你喜欢
False breakthroughs in the trend of London Silver
晶振是如何起振的?
黄金价格走势k线图如何看?
Dedecms plug-in free SEO plug-in summary
Unity | two ways to realize facial drive
Vulhub vulnerability recurrence 74_ Wordpress
Convert binary search tree into cumulative tree (reverse middle order traversal)
Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
普通人下场全球贸易,新一轮结构性机会浮出水面
Opinions on softmax function
随机推荐
Distributed base theory
Mysql--- query the top 5 students
Alibaba-Canal使用详解(排坑版)_MySQL与ES数据同步
How to get all sequences in Oracle database- How can I get all sequences in an Oracle database?
IP storage and query in MySQL
internship:项目代码所涉及陌生注解及其作用
leetcode刷题_验证回文字符串 Ⅱ
Introduction to robotics I. spatial transformation (1) posture, transformation
Who knows how to modify the data type accuracy of the columns in the database table of Damon
ORA-00030
Leetcode 剑指 Offer 59 - II. 队列的最大值
3D model format summary
A picture to understand! Why did the school teach you coding but still not
[Arduino syntax - structure]
【SSRF-01】服务器端请求伪造漏洞原理及利用实例
Mathematical modeling learning from scratch (2): Tools
Recommended areas - ways to explore users' future interests
Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
servlet(1)