当前位置:网站首页>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
边栏推荐
- SCM Chinese data distribution
- 基于DVWA的文件上传漏洞测试
- Crawler request module
- 3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)
- 【已解决】如何生成漂亮的静态文档说明页
- Huawei converged VLAN principle and configuration
- 直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
- MATLB | real time opportunity constrained decision making and its application in power system
- 【SSRF-01】服务器端请求伪造漏洞原理及利用实例
- Unity VR solves the problem that the handle ray keeps flashing after touching the button of the UI
猜你喜欢
随机推荐
Basic process and testing idea of interface automation
Obstacle detection
Vulhub vulnerability recurrence 74_ Wordpress
Leetcode 208. Implement trie (prefix tree)
Three methods of script about login and cookies
Introduction to robotics I. spatial transformation (1) posture, transformation
Leetcode study - day 35
FFT learning notes (I think it is detailed)
Convert binary search tree into cumulative tree (reverse middle order traversal)
How to see the K-line chart of gold price trend?
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。
BiShe - College Student Association Management System Based on SSM
[day 30] given an integer n, find the sum of its factors
Idea sets the default line break for global newly created files
Nmap: network detection tool and security / port scanner
Paging of a scratch (page turning processing)
ctf. Show PHP feature (89~110)
基于DVWA的文件上传漏洞测试
Fibonacci number
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once