zoukankan      html  css  js  c++  java
  • Spring Boot 整合 jdbctemplate 单数据源

    参考地址:https://www.cnblogs.com/huasonglin/p/10817940.html

    1.pom.xml引包

    <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
    
            <!-- 引入jdbc支持 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <!-- 连接MySQL数据库 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.46</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!-- 生成api文档 -->
    
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.2.2</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.2.2</version>
            </dependency>
        </dependencies>

    2. 在application.properties配置连接MySQL数据库

    spring.datasource.url=jdbc:mysql://localhost:3306/test_db?serverTimezone=GMT%2B8&useSSL=false
    spring.datasource.username=root
    spring.datasource.password=123456
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  • 相关阅读:
    事务 TRANSACTION
    SQLServer 数据库镜像+复制切换方案
    微软 codeplex 团队
    codeplex http://metrotoolkit.codeplex.com/
    CodeFlex AutoUpdate
    微软学习网站
    C# 关闭窗体立即停止进程
    反射方法关闭窗体报错的解决方法
    params修饰符
    c# 条形码(求指教)
  • 原文地址:https://www.cnblogs.com/gjq1126-web/p/13958980.html
Copyright © 2011-2022 走看看