首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Spring Boot 与 Kotlin 使用JdbcTemplate连接MySQL

    首先,为了连接数据库需要引入jdbc支持,在 build.gradle中引入如下配置: compile "org.springframework.boot:spring-boot-starter-jdbc...:$spring_boot_version" 连接数据源 以MySQL数据库为例,先引入MySQL连接的依赖包,在 build.gradle中加入: compile "mysql:mysql-connector-java..." compile "mysql:mysql-connector-java:$mysql_version" testCompile "org.springframework.boot:spring-boot-starter-test...driver-class-name: com.mysql.jdbc.Driver 连接JNDI数据源 当你将应用部署于应用服务器上的时候想让数据源由应用服务器管理,那么可以使用如下配置方式引入JNDI数据源...我们只需要在pom.xml中加入数据库依赖,再到application.yml中配置连接信息,不需要像Spring应用中创建JdbcTemplate的Bean,就可以直接在自己的对象中注入使用。

    2.2K30
    领券