当前位置:   article > 正文

Springboot整合mysql 5.7 实现增删改查_springboot2 mysql5.7

springboot2 mysql5.7

出现 Cannot resolve class or package ‘mysql’处理方法
https://blog.csdn.net/zhouhan_0509/article/details/127319458

这个是因为连接mysql的版本的关系,cj是8.0的

Failed to obtain JDBC Connection; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsExc

https://blog.csdn.net/RavenWE/article/details/121482923

useSSL=false和true的区别
https://blog.csdn.net/sungancd/article/details/119183605

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>kafka</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!--springboot启动类依赖导入-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.2.RELEASE</version>
        <relativePath/>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.71</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>

    </dependencies>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58

SpringBoot中Server层以及Mapper层常用注解

SpringBoot项目连接MySQL数据库

IDEA创建Mapper.xml文件

mapper层
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
批量修改或者新增
在这里插入图片描述

@Controller
@RequestMapping("/hello")
public class Test1Controller {

    @Autowired
    private OrderServiceImpl orderServiceImpl;

    @RequestMapping("/h")
    public void test(){
       // System.out.println(orderService.findById());

        /*Order order = new Order();
        order.setOrderName("圣女果");
        order.setOrderId(4L);
        order.setFeature("贵且好吃");
        System.out.println(order);
        //orderService.updateById(order);
        System.out.println(orderServiceImpl.saveOrUpdate(order));*/

        List <Order> orderList = new ArrayList<>();
        orderList.add(new Order().setOrderId(1L).setOrderName("批量修改"));
        orderList.add(new Order().setOrderId(5L).setOrderName("新增水果").setNumber("100005").setFeature("批量新增或者修改测试"));
        System.out.println(orderServiceImpl.saveOrUpdateBatch(orderList));
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/576606
推荐阅读
相关标签
  

闽ICP备14008679号