当前位置:网站首页>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此类注解就涉及到数据库表建立实体类
边栏推荐
- Ubantu check cudnn and CUDA versions
- CocoaPods could not find compatible versions for pod 'Firebase/CoreOnly'
- VMware Tools installation error: unable to automatically install vsock driver
- How to see the K-line chart of gold price trend?
- Who knows how to modify the data type accuracy of the columns in the database table of Damon
- Installation and use of esxi
- The inconsistency between the versions of dynamic library and static library will lead to bugs
- 记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
- ORA-00030
- Leetcode1961. Check whether the string is an array prefix
猜你喜欢
282. Stone consolidation (interval DP)
What is the most suitable book for programmers to engage in open source?
VMware Tools安装报错:无法自动安装VSock驱动程序
毕设-基于SSM高校学生社团管理系统
File upload vulnerability test based on DVWA
False breakthroughs in the trend of London Silver
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
JVM_ 15_ Concepts related to garbage collection
MUX VLAN configuration
The growth path of test / development programmers, the problem of thinking about the overall situation
随机推荐
Overview of Zhuhai purification laboratory construction details
Programmer growth Chapter 9: precautions in real projects
Dede collection plug-in free collection release push plug-in
Live video source code, realize local storage of search history
Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
SSH login is stuck and disconnected
MobileNet系列(5):使用pytorch搭建MobileNetV3并基于迁移学习训练
Development trend of Ali Taobao fine sorting model
Leetcode1961. Check whether the string is an array prefix
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
Leetcode 208. Implement trie (prefix tree)
Mathematical modeling learning from scratch (2): Tools
Obstacle detection
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
How to get the PHP version- How to get the PHP Version?
MATLB|实时机会约束决策及其在电力系统中的应用
2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
IP storage and query in MySQL