1.

How To Configure Datasource Using Spring Boot?

Answer»

Use EITHER SPRING-boot-starter-jdbc or spring-boot-starterdata-jpa and include a JDBC driver on classpath

Declare properties:

spring.datasource.url=jdbc:mysql://localhost/test

spring.datasource.username=dbuser

spring.datasource.password=dbpass

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

  • Spring Boot will create a DataSource with properties set
  • Will even use a connection POOL if the LIBRARY is found on the classpath.

Use either spring-boot-starter-jdbc or spring-boot-starterdata-jpa and include a JDBC driver on classpath

Declare properties:

spring.datasource.url=jdbc:mysql://localhost/test

spring.datasource.username=dbuser

spring.datasource.password=dbpass

spring.datasource.driver-class-name=com.mysql.jdbc.Driver



Discussion

No Comment Found