Adding JDBC Connectivity
At this point we are ready to create a full-blown Spring MVC project from Spring Boot 2.0 with a database backend. This recipe will showcase how to add a starter POM that will auto-configure all APIs for the implementation of java.sql.DataSource
needed by all the JDBC transactions of EmployeeDao
and DepartmentDao
.
Getting started
Open again current Maven project ch09
and add a new POM starter to implement the JDBC transactions using MySQL.
How to do it...
Using the previous DAO and service layer, let us implement a Spring Boot 2.0 application by doing the following steps:
- Open
pom.xml
and add the following starter for the Spring Boot application:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency>
Note
Since this starter uses HikariCP
as a default connection pooling plugin, including Maven dependencies on HikariCP
is now not recommended.
- Add the MySQL connector...