当前位置:网站首页>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此类注解就涉及到数据库表建立实体类
边栏推荐
- Leetcode 208. 实现 Trie (前缀树)
- IP storage and query in MySQL
- Huawei Hrbrid interface and VLAN division based on IP
- Dynamic programming -- linear DP
- JVM_ 15_ Concepts related to garbage collection
- 95后CV工程师晒出工资单,狠补了这个,真香...
- After 95, the CV engineer posted the payroll and made up this. It's really fragrant
- Zhuhai laboratory ventilation system construction and installation instructions
- How to get the PHP version- How to get the PHP Version?
- 在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
猜你喜欢
95后CV工程师晒出工资单,狠补了这个,真香...
Docker compose配置MySQL并实现远程连接
Condition and AQS principle
Differences between standard library functions and operators
Mathematical modeling learning from scratch (2): Tools
MATLB|实时机会约束决策及其在电力系统中的应用
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
程序员搞开源,读什么书最合适?
Four commonly used techniques for anti aliasing
Dedecms plug-in free SEO plug-in summary
随机推荐
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
Vulhub vulnerability recurrence 74_ Wordpress
Is chaozhaojin safe? Will it lose its principal
Obstacle detection
Kotlin core programming - algebraic data types and pattern matching (3)
Nmap: network detection tool and security / port scanner
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
BiShe - College Student Association Management System Based on SSM
C language programming (Chapter 6 functions)
Differences between standard library functions and operators
Idea sets the default line break for global newly created files
基於DVWA的文件上傳漏洞測試
What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
WGet: command line download tool
Interview must brush algorithm top101 backtracking article top34
Ordinary people end up in Global trade, and a new round of structural opportunities emerge
黄金价格走势k线图如何看?
Leetcode 208. 实现 Trie (前缀树)
Dede collection plug-in free collection release push plug-in
Crawler request module