[JAVA] Create Spring Boot environment with Windows + VS Code

Thing you want to do

I want to create an environment to run Spring Boot on Windows. If I do it on Windows, I feel that it is modern to make it on WSL and develop it with VS Code, so I aim for that. First run it on Windows only, then on WSL.

What i did

Runs only on Windows

OpenJDK installation

Download the JDK for Windows as a zip from http://jdk.java.net/14/ and unzip it. Move the created folder to an appropriate path. This time, I put it under C: \ Program Files \ Java \ jdk-14.

Also, set the following in the system environment variables.

Variable value
JAVA_HOME C:\Program Files\Java\jdk-14
Path Add% JAVA_HOME% bin at the beginning

VS Code settings

Extension installation

I installed the following.

java.home settings

Specify the JDK path in settings.json as shown below (add any other items).

{
    "java.home": "C:\\Program Files\\Java\\jdk-14"
}

If you search by entering java.home on the settings screen, a link to edit in settings.json will appear.

Create and run a Java project as a trial

Open the command palette with Ctrl + Shift + P and run Create Java Project. After entering the save location and project name appropriately, the project will be created and opened with VS Code. Debug with F5 and check if Hello Java is displayed.

Create and run Spring project as a trial

Open the command palette with Ctrl + Shift + P and run Spring Initiallizr: Generate a Gradle Project. (You can create it with Maven, but with Gradle)

Create a dependent package empty for the time being and execute it. It's OK if the Spring logo appears on the debug console and it is executed.

Run on WSL

OpenJDK installation

Install OpenJDK on WSL. It seems that OpenJDK11 can be installed with the apt command, so use this.

$ sudo apt update
$ sudo apt install -y openjdk-11-jdk

gradle installation

It seems old if you put it in with apt, but for the time being.

$ sudo apt install -y gradle

VS Code settings

Extension installation

First, install the following.

If you type code in the WSL terminal after installation, VS Code for the WSL environment will be launched. In that state, install the extension installed with VS Code for Windows again.

java.home settings

Change the value of java.home set in settings.json.

{
    "java.home": "/usr/lib/jvm/java-11-openjdk-amd64"
}

Create and run a Java project as a trial

Open the command palette with Ctrl + Shift + P and run Create Java Project. After entering the save location and project name appropriately, the project will be created and opened with VS Code. Debug with F5 and check if Hello Java is displayed.

Create and run Spring project as a trial

Open the command palette with Ctrl + Shift + P and run Spring Initiallizr: Generate a Gradle Project. Create a dependent package empty for the time being and execute it. It's OK if the Spring logo appears on the debug console and it is executed.

Try Spring Web

Create with the settings to use Spring Web when creating a project with Spring Initiallizr. Add @RestController annotation to Application class where main () is located, and create the following method in the class.

@GetMapping("/")
String home() {
    return "Hello!";
}

Run the application, access http: // localhost: 8080 /, and if Hello! Is displayed, it's OK. Repository: https://github.com/stamefusa/spring-web-demo

Referenced entry

https://qiita.com/dongsu-iis/items/6c7974022083d3036dc8

https://qiita.com/gitcho/items/a6c0bb781bc395e43ec4 https://qiita.com/gitcho/items/147a3ce2536ae3035bb8

Recommended Posts

Create Spring Boot environment with Windows + VS Code
Spring Boot programming with VS Code
Beginners create Spring Tools Suite environment with VS Code
Try using Spring Boot with VS Code
Create a Spring Boot development environment with docker
Create microservices with Spring Boot
Introduction to Java development environment & Spring Boot application created with VS Code
Build ruby debug environment with VS Code of Windows 10
Create an app with Spring Boot 2
Create RUNTEQ's environment with Windows DockerDesktop
Java Spring environment in vs Code
Create an app with Spring Boot
Prepare Java development environment with VS Code
Create Spring Boot development environment on Vagrant
Create Spring Boot-gradle-mysql development environment with Docker
Building a haskell environment with Docker + VS Code on Windows 10 Home
Spring Boot environment construction with Docker (January 2021 version)
Create a website with Spring Boot + Gradle (jdk1.8.x)
Lombok with VS Code
Create a simple search app with Spring Boot
Run a Spring Boot project in VS Code
Spring boot development-development environment-
Build Spring Boot project by environment with Gradle
Create CRUD apps with Spring Boot 2 + Thymeleaf + MyBatis
Create your own Utility with Thymeleaf with Spring Boot
Create a web api server with spring boot
Download with Spring Boot
Create Spring Cloud Config Server with security with Spring Boot 2.0
Build a Java development environment with VS Code
From creating a Spring Boot project to running an application with VS Code
Build Java development environment with VS Code on Mac
Switch environment with Spring Boot application.properties and @Profile annotation
SSO with GitHub OAuth in Spring Boot 1.5.x environment
Create a simple demo site with Spring Security with Spring Boot 2.1
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
How to boot by environment with Spring Boot of Maven
[Environment construction] Build a Java development environment with VS Code!
Database environment construction with Docker in Spring boot (IntellJ)
Create Chisel development environment with Windows10 + WSL2 + VScode + Docker
[Spring Boot] Environment construction (macOS)
Generate barcode with Spring Boot
Hello World with Spring Boot
Implement GraphQL with Spring Boot
Docker management with VS Code
Get started with Spring boot
Hello World with Spring Boot!
Format Ruby with VS Code
Run LIFF with Spring Boot
SNS login with Spring Boot
Hello World with VS Code!
File upload with Spring Boot
Create a VS Code Plugin.
Spring Boot starting with copy
Spring Boot starting with Docker
Hello World with Spring Boot
Set cookies with Spring Boot
Use Spring JDBC with Spring Boot
Docker ├Ś Spring Boot environment construction
Add module with Spring Boot
Getting Started with Spring Boot