@NoArgsConstructor(access = AccessLevel.PRIVATE)
时间: 2024-02-22 18:35:25 浏览: 192
@NoArgsConstructor(access = AccessLevel.PRIVATE)是一个注解,它的作用是为类生成一个私有的无参构造方法。这个注解被应用在类的定义上,并且在编译后会生成一个私有的无参构造方法。 这个构造方法可以被用于在类内部进行初始化操作。例如,在User类中,使用@NoArgsContructor(access = AccessLevel.PRIVATE)注解可以生成一个私有的无参构造方法,确保这个类的实例只能通过其他公共的静态方法来创建。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Lombok--使用](https://blog.csdn.net/feiying0canglang/article/details/106725810)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [lombok注解详解-@NoArgsConstructor、@RequiredArgsConstructor、@AllArgsConstructor的使用](https://blog.csdn.net/weixin_41298656/article/details/118896052)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文