[JAVA] Spring Boot DB related tips

Studying Spring Boot at "First Spring-Boot". I wrote a good thing about DB related settings, so I will introduce it.

Automatically loaded SQL file

In Spring Boot, if the following SQL file exists directly under the classpath (src / main / resources / *. sql), it will be read and executed.


When using Japanese for SQL files



H2 DB settings



If you want to make it persistent, change the url as follows


Settings for persistence spring.datasource.url=jdbc:h2:file:./target/db/testdb

Log4 SQL log output using JDBC


--JDBC driver settings for Log4 JDBC



--Log4 Log level setting for JDBC




--First Spring-Boot https://www.amazon.co.jp/s/ref=a9_sc_1/357-5571034-7925567?rh=i%3Aaps%2Ck%3Aはじめてspring+boot&keywords=はじめてspring+boot&ie=UTF8&qid=1523177092

Recommended Posts

Spring Boot DB related tips
Spring Boot performance related settings
Spring Boot DB connection pool
Challenge Spring Boot
Spring Boot Form
Spring Boot Memorandum
gae + spring boot
SPRING BOOT learning record 01
Spring Boot + Heroku Postgres
Spring boot memo writing (1)
First Spring Boot (DI)
SPRING BOOT learning record 02
Spring Boot2 cheat sheet
Spring Boot exception handling
Spring boot development-development environment-
Spring Boot learning procedure
Learning Spring Boot [Beginning]
Spring boot memo writing (2)
Spring Boot 2.2 Document Summary
[Spring Boot] DataSourceProperties $ DataSourceBeanCreationException
Spring Boot 2.3 Application Availability
Spring boot tutorials Topics
Download with Spring Boot
[Spring Boot] Environment construction (macOS)
Set context-param in Spring Boot
Try Spring Boot from 0 to 100.
Generate barcode with Spring Boot
Hello World with Spring Boot
Implement GraphQL with Spring Boot
Spring Boot tutorial task schedule
Spring 5 & Spring Boot 2 Hands-on preparation procedure
Get started with Spring boot
Hello World with Spring Boot!
Spring Boot 2 multi-project in Gradle
[Spring Boot] Web application creation
spring boot port duplication problem
Spring Boot Hot Swapping settings
[Java] Thymeleaf Basic (Spring Boot)
Introduction to Spring Boot ① ~ DI ~
File upload with Spring Boot
Spring Boot starting with copy
Introduction to Spring Boot ② ~ AOP ~
Spring Boot starting with Docker
Java tips --Spring execution Summary
Hello World with Spring Boot
Set cookies with Spring Boot
[Spring Boot] Easy paging recipe
Use Spring JDBC with Spring Boot
Docker × Spring Boot environment construction
Major changes in Spring Boot 1.5
Add module with Spring Boot
Getting Started with Spring Boot
NoHttpResponseException in Spring Boot + WireMock
[Spring Boot] Send an email
Spring Boot application that specifies DB connection settings with parameters
Introduction to Spring Boot Part 1
Spring Boot External setting priority
Try using Spring Boot Security
[Java] [Spring] Spring Boot 1.4-> 1.2 Downgrade Note
Try Spring Boot on Mac
Create microservices with Spring Boot