Create a simple DRUD application with Java + SpringBoot + Gradle + thymeleaf (1)

Introduction

It's been almost a year and a half since I changed jobs to an engineer, so it's about time I started thinking that I should be able to develop basic apps with Java and Spring Boot. The reference book I am currently using is Introduction to Spring Boot 2 Programming. I haven't been able to practice everything while moving my hands yet, but I've done it until I created a simple app, so I will summarize it. It was a good study because I created it with my own original code in some places. I would like to write it after reviewing it in several parts.

github: https://github.com/noydmt/myboot

First, from the explanation of the tools and FW used.

Gradle Build tool by Groovy. Build information and processing is described in Groovy. Groovy is a kind of programming language that can be written with a grammar that follows Java, and you can also create apps. In addition to the description of Gradle, it is often used when making a prototype before full-scale application development. Unlike maven, pom.xml is not used, and the build.gradle file is placed in the project to manage the environment. When creating a project with STS, it is necessary to install a plug-in tool dedicated to gradle in advance, and it seems that you often start with STS, so Help => Eclipse Marketplace => " Buildship You can create a gradle project by installing => Buildship gradle integration.

Thymeleaf A template library made for Java. Since it is built into Spring Boot by default, there is no need to install any libraries. It is possible to display the screen using th or$ {}, which does not affect HTML unlike JSP. To be honest, in my personal opinion, I don't think the taste of learning a template engine is that great.

SpringBoot A Java framework that is further extended based on the Spring framework. Its strength is that it can be developed at high speed like rails. Like the Spring framework, it also has DI, so there is no need to bother to create an instance of the class you want to use in the dependent class. I searched for AOP, but I'm not sure.

Next, I will introduce the environment actually used in application development.

build.gradle

build.gradle



plugins {
	id 'org.springframework.boot' version '2.3.4.RELEASE'
	id 'io.spring.dependency-management' version '1.0.10.RELEASE'
	id 'java'
}

group = 'com.gradle.springboot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
	mavenCentral()
}

dependencies {
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-thymeleaf')
	compile('org.hsqldb:hsqldb')
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
}

test {
	useJUnitPlatform()
}

If you take a quick look at the contents, plugins, repositories, and dependencies are the components of this file. In plugins, the languages ​​used such as Java, springBoot, and dependency are used. Frameworks, management tools, versions, etc. are managed. Please note that the functions that can be used may be limited depending on the version. That said, it is the dependencies that individual developers are more likely to mess with. With this dependencies, you just need to describe in advance what kind of library you want to use, and it will download it at build time. If there is a library you want to use without using build.gradle, you can't use it without downloading the jar file from the outside and passing it through the classpath, but gradle uses the library without such trouble. You can do it.

The library I used this time is as follows. ・ Spring Boot ・ Thymeleaf · HSQLDB ・ JPA

HSQLDB allows you to embed a DB inside a Java application and can store the database in memory instead of on the original server. Often used as a development test database. Since it is stored in memory, it is volatile, and once the record is stored, it disappears when the application is restarted.

JPA is an OR mapper that can realize RDB table operations more easily by using entity classes.

Continue to next time. .. ..

Recommended Posts

Create a simple DRUD application with Java + SpringBoot + Gradle + thymeleaf (1)
Create a simple CRUD with SpringBoot + JPA + Thymeleaf ③ ~ Add Validation ~
Create a simple web application with Dropwizard
Create a simple bulletin board with Java + MySQL
Create a simple CRUD with SpringBoot + JPA + Thymeleaf ② ~ Screen and function creation ~
Build a Java project with Gradle
Make a simple CRUD with SpringBoot + JPA + Thymeleaf ① ~ Hello World ~
Make a simple CRUD with SpringBoot + JPA + Thymeleaf ⑤ ~ Template standardization ~
[Java] Create an executable module with Gradle
Create a simple on-demand batch with Spring Batch
[Rails withdrawal] Create a simple withdrawal function with rails
Create a simple bar chart with MPAndroidChart
Create a java web application development environment with docker for mac part2
Create a website with Spring Boot + Gradle (jdk1.8.x)
Create a simple search app with Spring Boot
Make SpringBoot1.5 + Gradle4.4 + Java8 + Docker environment compatible with Java11
Create a CSR with extended information in Java
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Let's create a timed process with Java Timer! !!
04. I made a front end with SpringBoot + Thymeleaf
[Java] Create a collection with only one element
CICS-Run Java application-(1) Run a simple sample app
Show a simple Hello World with SpringBoot + IntelliJ
[Java] Create a filter
Create a docker image that runs a simple Java app
[Beginner] Create a competitive game with basic Java knowledge
[Note] Create a java environment from scratch with docker
Create a simple demo site with Spring Security with Spring Boot 2.1
Create a JAVA WEB application and try OMC APM
Create a Java (Gradle) project with VS Code and develop it on a Docker container
Let's create a TODO application in Java 11 Exception handling when accessing TODO with a non-existent ID
[Azure] I tried to create a Java application for free ~ Connect with FTP ~ [Beginner]
Java multi-project creation with Gradle
Story of making a task management application with swing, java
I tried to modernize a Java EE application with OpenShift.
[Beginner] Try to make a simple RPG game with Java ①
Create a java method [Memo] [java11]
[Java] Create a temporary file
Create a playground with Xcode 12
Create a SlackBot with AWS lambda & API Gateway in Java
[Java] Draw a simple pattern
Until you create a Web application with Servlet / JSP (Part 1)
Try developing a containerized Java web application with Eclipse + Codewind
Create a Java and JavaScript team development environment (gradle environment construction)
Hello World with SpringBoot / Gradle
Let's create a TODO application in Java 13 TODO form validation 1: Character limit ・ Gradle update to use @Validated
Let's create a TODO application in Java 4 Implementation of posting function
I can't create a Java class with a specific name in IntelliJ
Let's create a TODO application in Java 6 Implementation of search function
Create a high-performance enum with fields and methods like Java with JavaScript
How to create a new Gradle + Java + Jar project in Intellij 2016.03
Let's create a TODO application in Java 8 Implementation of editing function
Let's create a TODO application in Java 1 Brief explanation of MVC
Let's create a TODO application in Java 5 Switch the display of TODO
[Gradle] Build a Java project with a configuration different from the convention
Draw screen with Thymeleaf in SpringBoot
Create an immutable class with JAVA
Create a Vue3 environment with Docker!
Implement text link with Springboot + Thymeleaf
Preparing to create a Rails application
3 Implement a simple interpreter in Java