欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

springboot整合mybatis plus與druid詳情

 更新時間:2022年09月28日 14:22:42   作者:<編程路上>  
這篇文章主要介紹了springboot整合mybatis plus與druid詳情,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的下伙伴可以參考一下

加坐標(biāo)可以使用https://mvnrepository.com/來查找

先加以下坐標(biāo):

使用的數(shù)據(jù)庫介紹:

配置連接數(shù)據(jù)庫:

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/spring?serverTimezone=UTC
    username: root
    password: 123456

定義類:

package com.spring1.domain;

import com.baomidou.mybatisplus.annotation.TableName;

@TableName("student")
public class student {
    private Integer id;
    private String name;
    private String age;

    @Override
    public String toString() {
        return "student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
}

測試:

package com.spring1;

import com.spring1.dao.StudentDao;
import com.spring1.domain.student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class Spring1ApplicationTests {

    @Autowired
    private StudentDao studentDao;
    @Test
    void contextLoads() {
        System.out.println(studentDao.selectList(null));
    }

}
[student{id=1000, name='Li Ming', age='22'}, student{id=1001, name='Danny', age='17'}, student{id=1002, name='Li Gang', age='22'}, student{id=1003, name='Jenny', age='19'}, student{id=1004, name='Jim', age='19'}]

添加druid

添加坐標(biāo):

配置修改:

spring:
  datasource:
    druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
       url: jdbc:mysql://localhost:3306/spring?serverTimezone=UTC
       username: root
       password: 123456

到此這篇關(guān)于springboot整合mybatis plus與druid詳情的文章就介紹到這了,更多相關(guān)springboot整合 druid內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論