Spring Boot Visual Studio Code



Spring Boot Visual Studio Code

Visual Studio Code Spring Boot Project

This extension for Visual Studio Code adds useful snippets for Spring Boot. These are especially useful for creating REST apis, and configuring database connection properties.

Usage

For a detailed walkthrough, please use this youtube video - https://www.youtube.com/watch?v=qI7hTw8aMaU

Type part of a snippet, press enter, and the snippet unfolds.

Alternatively, press Ctrl+Space (Windows, Linux) or Cmd+Space (macOS) to activate snippets from within the editor.

Java Snippets

SnippetPurpose
spring-crudctrlSpring controller with CRUD actions implemented
spring-crudrepoSpring Data JPA CRUD repository with REST api annotation
spring-jparepoSpring Data JPA repository with REST api annotation
spring-entityJPA entity with ID field
spring-lombok-entityJPA entity with ID field and Lombok @Data annotation
spring-ctrl-getallController GET action for collection
spring-ctrl-getoneController GET action for single item
spring-ctrl-postController POST action
spring-ctrl-putController PUT action
spring-ctrl-deleteController DELETE action

application.properties / application.yaml Snippets

SnippetPurpose
spring-sqliteSQLite database jdbc url and properties
spring-sqlserverSQL Server database jdbc url and properties
spring-oracleOracle database jdbc url and properties
spring-postgresqlPostgreSQL database jdbc url and properties
spring-mysqlMySQL database jdbc url and properties
spring-h2H2 database jdbc url and properties

Installation

  1. Install Visual Studio Code 1.44.0 or higher
  2. Launch Code
  3. From the command palette Ctrl-Shift-P (Windows, Linux) or Cmd-Shift-P (OSX)
  4. Select Install Extension
  5. Choose the extension
  6. Reload Visual Studio Code

Tired of writing boilerplate code for your CRUD controller? This video shows you how to use an awesome Visual Studio Code extension to easily and quickly ge. Unlike JavaScript, Java code needs to be compiled so it wont work out of the box with visual studio code since it's just a glorified text editor. There are however multiple tools to accommodate for this, and the folks at VS code have a nice guide for setting you up - https://code.visualstudio.com/docs/java/java-spring-boot.

Spring Boot Vs Code

  1. Testing Java with Visual Studio Code. Testing Java in Visual Studio Code is enabled by the Java Test Runner extension. It's a lightweight extension to run and debug Java test cases. The extension supports the following test frameworks: Note: More information.
  2. Extension for Visual Studio Code - Provides validation and content assist for Spring Boot `application.properties`, `application.yml` properties files. As well as Boot-specific support for `.java` files.