Spring Boot development with VSCode and WSL2
Saturday, March 27th 2021

In this article we will get a development setup for Spring Boot projects using VSCode and WSL2.

It's been a while since I last tried to use VSCode for Java development. Last time I decided not to make the switch from IntelliJ IDEA.IntelliJ IDEA is a wonderful project. Jetbrains have trully created something beautiful. There's only a small caveat. It costs lots of money.Ever try to convince your boss to switch development for your team from something free (Netbeans, Eclipse [sic]) to IDEA? The argument "can do the same things but more efficiently, and it costs loads of money" doesn't fly well.

Here's how to get a development setup ready for free!

First enable WSL2 using this guide.Then you want to install a WSL2 distribution. I use debian. You can use whatever you like.

Enable the following extensions in VSCode:

  • Java extension pack (vscjava.vscode-java-pack): Installs Java language support, a debugger, maven support etc.
  • Java code generators (sohibe.java-generate-setters-getters): This is a convenience extension. It allows for the automatic creation of getters/setters/constructors etc.
  • Spring Boot Dashboard (vscjava.vscode-spring-boot-dashboard): Adds integration with the VSCode UI and allows Spring Boot projects to be started from within VSCode.

Reload VSCode just to be sure and let's get started.

Now that VSCode has been restarted you will notice that there is a new icon on the sidebar.

null

Assuming you have correctly installed WSL2 and a distribution, you should be able to "see" into the distro from this view.You can either create a new project within WSL2 or clone your existing projects. I have cloned under my home directory in WSL2.

From the sidebar you can now:

  • View and navigate JAVA projects.
  • View and execute maven goals.
  • Start / Debug your Spring Boot project.

null

You should now have a modern IDE for working with Java including features such as IntelliSense, integrated debugger and many more.I have been using this setup for more than 3 months and I am quite happy with it. I really don't miss any features of IDEA.

One added benefit of using VSCode is that you can import multiple projects using a workspace. These projects can (in my case) also include a front-end application. This way you can code / run / debug your entire application from within VSCode.