1、引入jdbc支持,需要在pom.xml中添加依赖包:
<!--SpringBoot 添加jdbc支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--添加Oracle连接的依赖包-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.1-atlassian-hosted</version>
</dependency>
2、在application.properties 文件中配置连接参数:
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=userstudy
spring.datasource.password=userstudy
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
3、添加Controller类、Service接口、ServiceImpl实现类