请教Controller跟Service里@AllArgsConstructor 注解作用?
因为看到源码部分有这个注解部分没有这个注解.作用是什么?何时该用这个注解在Controller跟Service上?
=======更新20191128==========
我还描述的不够清楚看来.
我了解@AllArgsConstructor是lombok,生成全参构造函数用的.用于一般Entity/model对象上常用.
但是用于service/controller上,也为了生成全参构造函数?生成全参构造函数干啥用呢?
https://blog.csdn.net/fwk19840301/article/details/91430905
https://blog.csdn.net/Tybyqi/article/details/82872183
https://blog.csdn.net/github_38222176/article/details/79506392
https://www.baeldung.com/spring-injection-lombok
评论部分:
Slava Semushin
I don’t understand why the examples use @AllArgsConstructor while they actually should use @RequiredArgsConstructor. With the current approach, if you add another non-final member, code will be broken. However with @RequiredArgsConstructor it will continue to work.
0
2 years ago
Guest
Grzegorz Piwowarek
Well, it depends. I rarely use non-final fields and if I add one by mistake I’d love to be punished by a compiler and reminded that I did something wrong
扫一扫访问 Blade技术社区 移动端