Studying Spring Boot at "First Spring-Boot". I wrote a good thing about DB related settings, so I will introduce it.
In Spring Boot, if the following SQL file exists directly under the classpath (src / main / resources / *. sql), it will be read and executed.
schema-(platform).sql
schema.sql
data-(platform).sql
data.sql
src/main/resources/application.properties
spring.datasource.sql-script-encoding=UTF-8
src/main/resources/application.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
If you want to make it persistent, change the url as follows
spring.datasource.url=jdbc:h2:file:./target/db/testdb
Settings for persistence spring.datasource.url=jdbc:h2:file:./target/db/testdb
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
<version>0.2.7</version>
</dependency>
--JDBC driver settings for Log4 JDBC
src/main/resources/application.properties
spring.datasource.driver-class-name=net.sf.log4jdbc.DriverSpy
spring.datasource.url=jdbc:log4jdbc:abridgement
--Log4 Log level setting for JDBC
src/main/resources/application.properties
logging.level.jdbc=OFF
logging.level.jdbc.sqltiming=DEBUG
--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