1.maven引入对应的jar
<!-- 添加对jdbc 的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- 添加数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
2.properties中配置(注意对于高版本的jdbc的class文件是com.mysql.cj.jdbc.Driver,引入其他,启动时会报错)
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/ruoyi?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
3.直接引入
@Autowired
private JdbcTemplate jdbcTemplate;
就可意识用了
转载于:https://my.oschina.net/jhb4166/blog/2877583