fzlakers
fzlakers

Reputation: 311

Option for generating getters and setters not showing up on VS Code

So I'm trying to make a project using Spring Boot and I had been able to use the "Generate Setters/Getters" button before on this same file but for some reason that option is no longer available in the dropdown. Could someone provide an explanation for why this is and what may have happened to this option?

Upvotes: 25

Views: 46571

Answers (5)

Jaywant Narwade
Jaywant Narwade

Reputation: 165

Try this: Right click >> Source Action

  1. Right click and select 'Source Action'
  2. Right click and select
  3. List item'Source Action'
  4. Select 'Generate Getters and Setters...'
  5. Select fields of class and click ok.

Same step for construction generation also

Upvotes: 1

Madhu Sharma
Madhu Sharma

Reputation: 695

You might be missing the add-on "Java Code Generators" which you can download from the marketplace. I installed this and I was able to generate getters and setters.

The solution posted by Madhu works. I added the image below for anyone to follow along.

enter image description here

Upvotes: 39

Galip Çalışkan
Galip Çalışkan

Reputation: 411

Try this: Right click >> Source Action

See here for a list of actions.

  1. Right click and select 'Source Action' enter image description here

  2. Select 'Generate Getters and Setters...' enter image description here

  3. Select fields of class and click ok. enter image description here

Upvotes: 41

Jugaman
Jugaman

Reputation: 1

If you have "Java extension pack" from Microsoft installed. Do this:

-Right Click on the workbench.

-Click on Source Actions: VSCODE view

-Click on "Generate Getter and Setter": VSCODE view

-Select the attributes to which you want to generate the getters and setters

Upvotes: 0

fzlakers
fzlakers

Reputation: 311

Ah, I figured it out, apparently import lombok.Data handles all getters, setters, and other stuff in the background. This had the unexpected result of getting rid of the generate getters/setters option in the dropdown menu. I got rid of this import in the code and the menu option was back.

Upvotes: 3

Related Questions