From ca2689876ff69feebc4e83616b80e3fe9e1d4ac2 Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Sun, 18 Oct 2026 15:46:51 +0800 Subject: [PATCH] =?UTF-8?q?javaEEday09-Mybatis-=E5=9F=BA=E7=A1=80=E6=93=8D?= =?UTF-8?q?=E4=BD=9C-=E5=88=A0=E9=99=A4(=E9=A2=84=E7=BC=96=E8=AF=91SQL)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/inmind/mapper/EmpMapper.java | 3 ++- .../src/main/resources/application.properties | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java b/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java index 2c1efd5..c25c349 100644 --- a/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java +++ b/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java @@ -6,7 +6,8 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface EmpMapper { //定义方法 - @Delete("delete from emp where id = #{id};") + @Delete("delete from emp where id = #{id};")//#{}预编译的方式 +// @Delete("delete from emp where id = ${id};")//${}拼接的方式,有sql注入问题 int delete(Integer id);//想返回删除数据的个数 // void delete(Integer id);//不想获得删除数据的个数 } diff --git a/springboot-mybatis-crud/src/main/resources/application.properties b/springboot-mybatis-crud/src/main/resources/application.properties index c92c824..9737b62 100644 --- a/springboot-mybatis-crud/src/main/resources/application.properties +++ b/springboot-mybatis-crud/src/main/resources/application.properties @@ -3,4 +3,6 @@ spring.application.name=springboot-mybatis-crud spring.datasource.url= jdbc:mysql://localhost:3306/mybatis spring.datasource.username= root spring.datasource.password= 1234 -spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver \ No newline at end of file +spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver + +mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file