Visual Studio Code Spring Boot



  1. Spring Boot Tools
  2. Spring Boot Dashboard
  3. Vs Code Spring Boot Profile
  4. Visual Studio Code Spring Boot Dashboard Not Showing

In order to allow Spring Tools 4 to continue to visualize live data from the running applications, you need to start the boot app with -Dspring.jmx.enabled=true in order to activate the JMX endpoints. Managing Live Data Connections Press CTRL-SHIFT-P (or CMD-SHIFT-P on Mac) and select the command to 'Manage Live Spring Boot Process Connections'. Spring Boot support in Visual Studio Code Spring Boot in Visual Studio Code Visual Studio Code is an ideal lightweight development environment for Spring Boot application developers and there are several useful VS Code extensions including. Once you are signed in to your Azure account and you have your app open in Visual Studio Code, select the Azure icon in the Activity Bar to open the Azure Explorer and you will see the Azure Spring Cloud panel. Right-click on your subscription and select Create Service in Portal.

Overview

In this tutorial, we are going to learn how to how to build a Spring Boot REST CRUD application with PostgreSQL database as backend and Visual Studio Code as editor.

Technologies Used

  • Java 1.8
  • Spring Boot 2.2.6
  • PostgreSQL Database
  • Visual Studio Code
  • Postman (to test API)

Project Structure

  • EmployeeController contains mapping methods to handle RESTful requests.
  • IEmployeeDAO deals with database operations.
  • EmployeeDAO is the implementation of IEmployeeDAO.
  • Employee is the Data Model class.
  • application.properties is the configuration file where we can add application configurations such as database configuration.
  • pom.xml contains dependencies of the project.

Database Setup

We are using PostgreSQL Database as backend for this project, first we need to install PostgreSQL and setup Database.

Download the latest version of PostgreSQL from here. After the installation run pgAdmin IDE to create and setup the database.

Create a database with name employee

Under Tools -> Query Tool, run the below script to create the table emp_master.

Create Spring Boot Project

In this project, we are using Visual Code to create the project. Visual Code is an Open Source and lightweight development environment developed by Microsoft. We can download it from here.

Refer Spring Boot in Visual Studio Code to create and run the project under Visual Studio Code.

Spring Boot Tools

Spring

POM Dependencies

We need to add the following project dependencies to pom.xml file.

Application Properties

Add database configurations to srcmainresourcesapplication.properties file.

Data Model

Create a model class forEmployee,

Data Access Objects

Create an Interface IEmployeeDAO with basic database CRUD functions,

Create implementation class EmployeeDAO for IEmployeeDAO,

Controllers

Finally we will create controllers to handle RESTful API requests,

Test with Postman

Conclusion

Spring Boot Dashboard

In this tutorial, we have learned how to create a Spring Boot REST CRUD API application using Visual Studio Code and PostgreSQL.

Vs Code Spring Boot Profile

The full source code of the sample used for this tutorial can be find on Github

Visual Studio Code Spring Boot Dashboard Not Showing

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




Comments are closed.