当前位置:网站首页>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
边栏推荐
- Leetcode daily question solution: 1189 Maximum number of "balloons"
- Huawei Hrbrid interface and VLAN division based on IP
- Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
- Some features of ECMAScript
- What is the most suitable book for programmers to engage in open source?
- What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
- 现货白银的一般操作方法
- ADS-NPU芯片架构设计的五大挑战
- MYSQL---查询成绩为前5名的学生
- Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
猜你喜欢
Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
Recommended areas - ways to explore users' future interests
一圖看懂!為什麼學校教了你Coding但還是不會的原因...
【已解决】如何生成漂亮的静态文档说明页
Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates
Finding the nearest common ancestor of binary tree by recursion
False breakthroughs in the trend of London Silver
Mathematical modeling learning from scratch (2): Tools
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
037 PHP login, registration, message, personal Center Design
随机推荐
ORA-00030
internship:项目代码所涉及陌生注解及其作用
Recursive method converts ordered array into binary search tree
037 PHP login, registration, message, personal Center Design
Construction plan of Zhuhai food physical and chemical testing laboratory
Leetcode study - day 35
朝招金安全吗 会不会亏损本金
[Yu Yue education] Liaoning Vocational College of Architecture Web server application development reference
XSS learning XSS lab problem solution
视频直播源码,实现本地存储搜索历史记录
Opinions on softmax function
Redis' cache penetration, cache breakdown, cache avalanche
黄金价格走势k线图如何看?
How does Huawei enable debug and how to make an image port
Docker compose配置MySQL并实现远程连接
Yii console method call, Yii console scheduled task
直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
基于DVWA的文件上传漏洞测试
2022 Guangxi Autonomous Region secondary vocational group "Cyberspace Security" competition and its analysis (super detailed)
【第30天】给定一个整数 n ,求它的因数之和