What I was addicted to when developing a Spring Boot application with VS Code

At the beginning

Recently, I've been trying various things to unify Java development into VS Code.

Some people were already addicted to the same thing, but as a memo to myself.

environment

For the time being, my environment set is posted, but the framework can be anything. (Reproduced in VSCode, Gradle environment.)

Event

Define additional dependent libraries in the dependencies of build.gradle. For example, let's add a dependency on Doma2 to our Spring Boot application.

build.gradle


// ...abridgement
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	runtimeOnly 'org.postgresql:postgresql'
	annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
	//Added dependency on Doma2
	annotationProcessor "org.seasar.doma.boot:doma-spring-boot-starter:1.4.0"
}
// ...abridgement

After downloading the dependency library, display the dependencies tree. (To confirm that the Doma2 dependency has been added)

// ...abridgement
|    \--- org.seasar.doma.boot:doma-spring-boot-autoconfigure:1.4.0
|         +--- org.seasar.doma.boot:doma-spring-boot-core:1.4.0
|         |    +--- org.seasar.doma:doma-core:2.35.0
|         |    +--- org.springframework:spring-context:4.3.25.RELEASE -> 5.2.7.RELEASE (*)
|         |    +--- org.springframework:spring-jdbc:4.3.25.RELEASE -> 5.2.7.RELEASE (*)
|         |    \--- org.springframework.data:spring-data-commons:1.13.23.RELEASE -> 2.3.1.RELEASE
|         |         +--- org.springframework:spring-core:5.2.7.RELEASE (*)
|         |         +--- org.springframework:spring-beans:5.2.7.RELEASE (*)
|         |         \--- org.slf4j:slf4j-api:1.7.26 -> 1.7.30
|         +--- org.springframework:spring-jdbc:4.3.25.RELEASE -> 5.2.7.RELEASE (*)
|         \--- org.springframework.boot:spring-boot-autoconfigure:1.5.22.RELEASE -> 2.3.1.RELEASE (*)
// ...abridgement

As a test, when I try to define the Entity class, the event that the automatic completion of annotations such as @ Entity and @ Table does not work occurs.

EmployeeEntity.java


// ...abridgement

@Getter
@Setter
// @Entity <-Auto-completion doesn't work!
// @Table(name = "employees") <-Auto-completion doesn't work!
public class EmployeeEntity {

  private Integer id;
  
  private String name;
  
}

Solution

VSCode's Java import completion reads .classpath like Eclipse, so you can regenerate .classpath when you add the dependent libraries.

build.gradle


plugins {
	id 'org.springframework.boot' version '2.3.1.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
	id 'eclipse' //add to
}

// ...abridgement
$ ./gradlew eclipse

BUILD SUCCESSFUL in 1s
3 actionable tasks: 3 executed

image-01.png OK!

At the end

After all it is a point that I personally like that it is lightweight.

However, in development cases such as loading user libraries, it seems that it is not yet a complete migration because it can only be handled by Eclipse.

reference

-Procedure (Windows 10) that I did when I prepared the environment of gradle + Java with VS Code

Recommended Posts

What I was addicted to when developing a Spring Boot application with VS Code
What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to
A memo that I was addicted to when making batch processing with Spring Boot
From creating a Spring Boot project to running an application with VS Code
What I was addicted to when implementing google authentication with rails
I tried to clone a web application full of bugs with Spring Boot
What I was addicted to when introducing the JNI library
Spring Boot programming with VS Code
A site that was easy to understand when I was a beginner when I started learning Spring Boot
What I was addicted to with the Redmine REST API
I was addicted to WSl when trying to build an android application development environment with Vue.js
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
Sample code to unit test a Spring Boot controller with MockMvc
Try using Spring Boot with VS Code
Memorandum: What I was addicted to when I hit the accounting freee API
A story I was addicted to when testing the API using MockMVC
Problems I was addicted to when building the digdag environment with docker
Run a Spring Boot project in VS Code
I was addicted to doing onActivityResult () with DialogFragment
I wanted to gradle spring boot with multi-project
Create Spring Boot environment with Windows + VS Code
[Spring Boot] Precautions when developing a web application with Spring Boot and placing war on an independent Tomcat server
03. I sent a request from Spring Boot to the zip code search API
SpringSecurity I was addicted to trying to log in with a hashed password (solved)
When introducing JOOQ to Spring boot, a story that was dealt with because an error occurred around Liquibase
A memorandum when creating a REST service with Spring Boot
I wrote a test with Spring Boot + JUnit 5 now
A story I was addicted to when getting a key that was automatically tried on MyBatis
I want to read the property file with a file name other than application.yml or application- [profile name] .yml with Spring Boot.
I tried to modernize a Java EE application with OpenShift.
What I was addicted to while using rspec on rails
I was addicted to setting default_url_options with Rails devise introduction
A memo to start Java programming with VS Code (2020-04 version)
I tried to get started with Swagger using Spring Boot
The story I was addicted to when setting up STS
A story I was addicted to with implicit type conversion of ActiveRecord during unit testing
[Circle CI] A story I was addicted to at Start Building
I was addicted to starting sbt
Spring Boot application code review points
I get a 404 error when testing forms authentication with Spring Security
[MacOS] I was disturbed by ruby when installing Spring Boot CLI
Let's make a book management web application with Spring Boot part3
Inquiry application creation with Spring Boot
Let's make a book management web application with Spring Boot part2
Settings to delete unused Java imports when saving with VS Code
I was angry with proc_open (): fork failed when trying to composer update inside a Docker container
I made a simple search form with Spring Boot + GitHub Search API.
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
I tried GraphQL with Spring Boot
How to open a script file from Ubuntu with VS code
I tried Flyway with Spring Boot
[Words spelled to me when I was in the first grade ⑦] What I want you to include at least with the Visual Studio Code extension
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
[Rails] I was addicted to the nginx settings when using Action Cable.
Spring Boot2 Web application development with Visual Studio Code SQL Server connection
My.cnf configuration problem that I was addicted to when I was touching MySQL 8.0 like 5.7
I was addicted to a simple test of Jedis (Java-> Redis library)
A memorandum when IME cannot be turned on with VS Code (Ubuntu 20.04)
[iOS] I tried to make a processing application like Instagram with Swift
Java beginner tried to make a simple web application using Spring Boot