搭建环境
数据库表的设计
create table bank(
id bigint auto_increment primary key ,
actno varchar ( 255 ) comment "账号" ,
balance decimal ( 15 , 2 ) comment "余额"
) ;
insert into bank values ( 1 , 'act001' , 50000 ) ;
insert into bank values ( 2 , 'act002' , 0 ) ;
添加依赖
< dependency>
< groupId> org.mybatis</ groupId>
< artifactId> mybatis</ artifactId>
< version> 3.5.10</ version>
</ dependency>
< dependency>
< groupId> mysql</ groupId>
< artifactId> mysql-connector-java</ artifactId>
< version> 8.0.30</ version>
</ dependency>
< dependency>
< groupId> junit</ groupId>
< artifactId> junit</ artifactId>
< version> 4.13.2</ version>
< scope> test</ scope>
</ dependency>
< dependency>
< groupId> ch.qos.logback</ groupId>
< artifactId> logback-classic</ artifactId>
< version> 1.2.11</ version>
</ dependency>
< dependency>
< groupId> jakarta.servlet</ groupId>
< artifactId> jakarta.servlet-api</ artifactId>
< version> 5.0.0</ version>
< scope> provided</ scope>
</ dependency>
< build>
< finalName> mybatis-004-web</ finalName>
< pluginManagement>
< plugins>
< plugin>
< artifactId> maven-clean-plugin</ artifactId>
< version> 3.1.0</ version>
</ plugin>
< plugin>
< artifactId> maven-resources-plugin</ artifactId>
< version> 3.0.2</ version>
</ plugin>
< plugin>
< artifactId> maven-compiler-plugin</ artifactId>
< version> 3.8.0</ version>
</ plugin>
< plugin>
< artifactId> maven-surefire-plugin</ artifactId>
<