Essential Spring Boot Snippets

This extension is optimized for developers who wants to develop Java Spring Boot applications. These code snippets contains Java and EditorConfig snippets.

This extension is still in progress. Let me know if you have any suggestion! Thanks!

Features

  • Provide Java, Controller, EditorConfig, JPA and VSCode User Settings snippets
  • Provide DTO snippets with Lombok & spring-boot-starter-validation dependency
  • Bundled with some must needed VSCode extensions

Code Snippets

Spring Boot (java)

Prefix Description
api-controller Generate RestController
api-get Spring Boot Controller GET action
api-get-all Spring Boot Controller GET action for all items
api-get-by-id Spring Boot Controller GET action for one item
api-get-query Spring Boot Controller GET action with RequestParam
api-post Spring Boot Controller POST action
api-put Spring Boot Controller PUT action
api-delete Spring Boot Controller DELETE action
api-dto Generate DTO class for an API action

The api-dto snippet need lombok and spring-boot-starter-validation dependencies been installed in the project.

Spring Data JPA (java)

Prefix Description
jpa-repository Generate Spring Data JPA Repository class
jpa-entity Generate Spring Data JPA Entity class

Spring Boot Properties (spring-boot-properties)

Prefix Description
jpa-datasource Setup Spring Data JPA datasource

Spring Boot Properties - YAML (spring-boot-properties-yaml)

Prefix Description
jpa-datasource Setup Spring Data JPA datasource

Java (java)

Prefix Description
sout Print a string to System.out
serr Prints a string to System.err
private_field Private field
public_field Public field
st String
thr throw new

EditorConfig (editorconfig)

Prefix Description
java Generates .editorconfig for Java project

VSCode User Settings (json)

Prefix Description
java Generates VSCode User Settings for Java projects
rest-client Generates VSCode user settings for REST Client

Apache Maven POM File (xml)

Prefix Description
pom-basic Generates POM Basic Structure
pom-aggregator Generates POM Aggregator Structure
pom-parent-snippet Generates POM <parent> snippet
pom-profiles Generates POM <profiles> snippet
pom-profile Generates POM <profile> snippet
jboss-web Generates WildFly/JBoss Web Deployment Descriptor (src/main/webapp/WEB-INF/jboss-web.xml)
wildfly-web Generates WildFly/JBoss Web Deployment Descriptor (src/main/webapp/WEB-INF/jboss-web.xml)

Extensions

This extension bundled with some MUST needed VSCode extensions for Java Spring Boot developments.

I also recommend the following extensions you MIGHT need.

  • Linting

    • Checkstyle for Java

      Provide real-time feedback about Checkstyle violations and quick fix actions

    • SonarLint

      SonarLint helps you detect and fix quality issues as you write code in Java.

  • Server Connectors

  • Java Tools

    • Gradle Language Support

      Add Gradle language support for Visual Studio Code

    • Gradle Tasks

      Run Gradle tasks in VS Code

    • Quarkus

      Quarkus Tools for Visual Studio Code is a feature-packed extension tailored for Quarkus application development within Visual Studio Code. You can quickly get started by using the extension's project generation and project debugging feature. The extension also provides amazing language features (completion, hover, validation etc.) for your project's application.properties file.

  • Containers and Microservices

    • Docker

      Build docker images and work with image registries.

    • Kubernetes

      It provides an explorer view to manage clusters and the nodes inside. It also provides advanced syntax support for editing Kubernetes manifest files.

  • Workbench

  • Git Version Control

Recommended VSCode User Settings

  • settings.json

    {
        "java.debug.settings.hotCodeReplace": "auto",
        "java.saveActions.organizeImports": true,
        "editor.foldingImportsByDefault": true
    }
  • .vscode/launch.json

    {
        "configurations": [
            {
                "type": "java",
                "request": "launch",
                "name": "Launch Spring Boot",
                "mainClass": "${workspaceFolder}/src/main/java/com/example/demo1/Demo1Application.java",
                "envFile": "${workspaceFolder}/.env"
            }
        ]
    }

    Remember change mainClass to your class that contains main() method.

Contributing

If you need any Java / Spring Boot snippets, please feel free to send PRs to me or simply drop me a note! 😊


Enjoy!