Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to resolve errors caused by Lombok's @ AllArgsConstructor annotation

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you how to solve the errors caused by Lombok's @ AllArgsConstructor annotation, which is concise and easy to understand. I hope you can gain something through the detailed introduction of this article.

Errors caused by the @ AllArgsConstructor annotation of Lombok

Requirements: a method is written in the Service implementation to call a third-party interface to synchronize data. The function code is not shown, and the more common calling APIs return JSON data.

Take a look at the error message started by SpringBoot:

Parameter 3 of constructor in org.springblade.modules.system.service.impl.UserServiceImpl required a bean of type 'java.lang.String' that could not be found.

A picture is attached:

After reading a lot of articles, they are talking about calling extra @ Autowired.

It can also be said that this is the reason, but I removed it from the Controller class without any effect. It turns out that @ Autowired annotations are really not used in the Controller layer.

At this point, you found @ AllArgsConstructor at the top of the Service implementation class.

Check the information. Here's a brief explanation.

The constructor of all parameters is generated automatically, and the scope of the annotation is only on the entity class, and the order of the parameters is consistent with the order of the attribute definition.

It's no problem to find that other classes write the same way. Because I added the @ Value annotation to this class. Read out the properties of the configuration file.

According to the explanation of the notes above

An all-parameter constructor is created, and the variable modified by @ Value is input as a constructor, resulting in an error report.

So just delete @ AllArgsConstructor.

Make a brief record. I hope it can help you. If there is anything wrong, I hope you can correct it. Thank you for taking the time to watch.

@ AllArgsConstructor lombok comments step on the pit record here to record the points for attention

@ AllArgsConstructor is placed on top of the class and acts like a full parameterized construct

However, if this class inherits from other classes, the fields in other classes will not appear in the full parameter construction.

Maybe my version is too low or something else. I can't find out why the parameters of the inherited class don't appear in the construction.

The above is how to solve the errors caused by the @ AllArgsConstructor annotation of Lombok. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report