当前位置:网站首页>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
边栏推荐
- [Arduino syntax - structure]
- leetcode刷题_验证回文字符串 Ⅱ
- The growth path of test / development programmers, the problem of thinking about the overall situation
- How does the crystal oscillator vibrate?
- After 95, the CV engineer posted the payroll and made up this. It's really fragrant
- How to see the K-line chart of gold price trend?
- What is the most suitable book for programmers to engage in open source?
- 3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)
- Introduction to robotics I. spatial transformation (1) posture, transformation
- Condition and AQS principle
猜你喜欢

3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)

Daily practice - February 13, 2022

晶振是如何起振的?

MUX VLAN configuration

leetcode刷题_验证回文字符串 Ⅱ

【详细】快速实现对象映射的几种方式

一圖看懂!為什麼學校教了你Coding但還是不會的原因...

【SSRF-01】服务器端请求伪造漏洞原理及利用实例

After 95, the CV engineer posted the payroll and made up this. It's really fragrant

How does the crystal oscillator vibrate?
随机推荐
Recoverable fuse characteristic test
黄金价格走势k线图如何看?
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction
Construction plan of Zhuhai food physical and chemical testing laboratory
Superfluid_ HQ hacked analysis
Finding the nearest common ancestor of binary tree by recursion
PHP error what is an error?
关于softmax函数的见解
Paging of a scratch (page turning processing)
Four commonly used techniques for anti aliasing
Leetcode daily question solution: 1189 Maximum number of "balloons"
CocoaPods could not find compatible versions for pod 'Firebase/CoreOnly'
The inconsistency between the versions of dynamic library and static library will lead to bugs
Leetcode 剑指 Offer 59 - II. 队列的最大值
What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
A Cooperative Approach to Particle Swarm Optimization
Unity | 实现面部驱动的两种方式
在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
Docker compose configures MySQL and realizes remote connection