当前位置:网站首页>internship:项目代码所涉及陌生注解及其作用
internship:项目代码所涉及陌生注解及其作用
2022-07-06 01:19:00 【ahyo】
建议实习的朋友可以在实习时记录下自己在实习过程中——每一天学了些什么 做了什么,在学的过程中多写写demo。
Lombok 中 @EqualsAndHashCode注解的使用:
主要的测试用例 是子类继承父类 实例化子类两个对象属性设置相同的值 利用equals进行比较,但结果为true,每一次实例化的对象都有一个hashcode,这是相比较的依据。
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("对象比较"+y1.equals(y2));
}
}
@EqualsAndHashCode(callSuper = true),就是用自己的属性和从父类继承的属性来生成hashcode;
@EqualsAndHashCode(callSuper = false),就是只用自己的属性来生成hashcode;
@Data相当于@Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode这5个注解的合集, 和@EqualsAndHashCode默认是false。
因此相应的解决方法——常在类的首部添加注解 @Data 或者@EqualsAndHashCode(callSuper=true)
@EqualsAndHashCode 主要为自动实现model类的equals方法和HashCode方法
值得一提的是——Model只是用来传输数据的,并不会进行业务的寻址。ModelAndView 却是可以进行业务寻址的,就是设置对应的要请求的静态文件,这里的静态文件指的是类似jsp的文件
ValueOperations是操作简单的value例如String工具类 操作的对象是redis数据库
一个类带了@Service注解,将自动注册到Spring容器,不需要再在applicationContext.xml配置文件中定义bean了,类似的还包括@Component、@Repository、@Controller。这也是为什么类首部添加@Service之后的属性或者方法啥的直接@Resource或者@Autowired
对于@Autowired的理解 自之前更熟知了一些:
1、一般接口类只有一个实现类 不管是按类型还是名字装配都没有问题
2、如果是一个接口类有多个实现类 那么需要属性名字跟组件名字一致,组件名字可以在声明的时候指定,比如 @Service(“”),属性名字跟组件名字不一致,配合@Qualifier注解指定组件名字。
再则就是之前的所涉及的api的常用注解
@TableField此类注解就涉及到数据库表建立实体类
边栏推荐
- Programmer growth Chapter 9: precautions in real projects
- Xunrui CMS plug-in automatically collects fake original free plug-ins
- Mysql--- query the top 5 students
- Unity | two ways to realize facial drive
- Recursive method converts ordered array into binary search tree
- Yii console method call, Yii console scheduled task
- VMware Tools安装报错:无法自动安装VSock驱动程序
- Opinions on softmax function
- After 95, the CV engineer posted the payroll and made up this. It's really fragrant
- Overview of Zhuhai purification laboratory construction details
猜你喜欢

Loop structure of program (for loop)

VMware Tools installation error: unable to automatically install vsock driver
![[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction](/img/b4/3d46a33fa780e5fb32bbfe5ab26a7f.jpg)
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction

毕设-基于SSM高校学生社团管理系统

Recoverable fuse characteristic test

Threedposetracker project resolution

VSphere implements virtual machine migration

Dede collection plug-in free collection release push plug-in

Cf:c. the third problem

Building core knowledge points
随机推荐
Four commonly used techniques for anti aliasing
Hundreds of lines of code to implement a JSON parser
WGet: command line download tool
网易智企逆势进场,游戏工业化有了新可能
VMware Tools installation error: unable to automatically install vsock driver
C language programming (Chapter 6 functions)
ADS-NPU芯片架构设计的五大挑战
Spir - V premier aperçu
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
In the era of industrial Internet, we will achieve enough development by relying on large industrial categories
Logstash clear sincedb_ Path upload records and retransmit log data
vSphere实现虚拟机迁移
Condition and AQS principle
The growth path of test / development programmers, the problem of thinking about the overall situation
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
Nmap: network detection tool and security / port scanner
MYSQL---查询成绩为前5名的学生
Leetcode sword finger offer 59 - ii Maximum value of queue
Crawler request module
logstash清除sincedb_path上传记录,重传日志数据