LomBok use (idea)

Springboot project LomBok use

  • LomBok simplify coding, is that you can use your annotations instead of javaBean the Getter, Setter, etc. Han Han Han repeated writing, but not LomBok tools or something api, it's just a plug-ide compiler Well, I Do not know what I am trying to listen would be finished
1. Introducing a file dependent coordinates pom
  • If the project is spring plus their own version
	<!-- lombok begin-->
	<dependency>
	    <groupId>org.projectlombok</groupId>
	    <artifactId>lombok</artifactId>
	    <scope>provided</scope>
	</dependency>
	<!-- lombok end-->
2. Install the plug LomBok
  • File-> setting-> Plugins, search LomBok download, I have downloaded it well, to not reboot ! ! ,
    Here Insert Picture Description
  • The following screen, the red circle on the check, click ok, the box will be prompted to restart the bomb, then restart.Here Insert Picture Description
3. Write a javaBean classes (entity classes) plus @Data comment
  • LomBok there are other notes, but I do not, do not record
  • Into the left view of the embodiment View-> ToolWIndows-> Structure , you can see all of the methods of the current classHere Insert Picture Description
4. Test class (and here I direct the Controller in writing)
	@GetMapping("/testLombok")
    @ResponseBody
    public String testLombok() {
        TestModel uu = new TestModel();
        uu.setAge(1);
        uu.setPassword("22");
        uu.setUsername("33");
        System.out.println(uu);
        return "success";
    }

operation result:

TestModel(username=33, password=22, age=1)

If you remember handy thumbs up!

Published 53 original articles · won praise 13 · views 2253

Guess you like

Origin blog.csdn.net/qq_36821220/article/details/103659883