目录
需要创建一个domain或者pojo或者entity包,在包下创建类
建个Dao包,在Dao包下创建类StuDao接口和StuCardDao接口
创建properties文件,我创建的名为jdbc.properties
先附上我创建所有工程后的工程目录,其中Student本工程无关,是我测试其他项目,可以忽略不建,Student,StudentDao和StudentDao.xml,不用构建
目录
需要创建一个domain或者pojo或者entity包,在包下创建类stu类
建个Dao包,在Dao包下创建类StuDao接口和StuCardDao接口
1、首先配置pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
</dependencies>
还需要添加扫描mapper文件和properties的路径
<resources>
<resource>
<directory>src/main/java</directory><!--所在的目录-->
<includes><!--包括目录下的.properties,.xml 文件都会扫描到-->
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
2、创建实体类stu和stuCard
需要创建一个domain或者pojo或者entity包,在包下创建类
stu类
private int sid;
private String sname;
private String age;
private String course;
private StuCard sc;
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getAge() {
return age;
}
public void setAge(String age)