Creating an entity class implements Serializable
field names and attribute names are consistent database
Date field need to import the package
to generate gettter and the setter, and then the method for generating a ToString
Create a persistence layer Dao
Create an interface
which defines a method findAll
created dao package, the shift into IUserDao
Mybits environment
Create xml file in the resources below
SqlMapConfig.xml
find a file inside the constraint to the
open Config constraints, copy
this constraint would lead over
then configure inside. The first is the configuration of the label
which is the first configuration environments, when you select a tag codes so many environments label generation.
Select the default default, default called mysql then the following id also called the mysql
basic configuration database information intercepted
dao independent configuration
起名com。然后再新建文件夹itheima,然后是dao文件夹
dao里面新建New File
IUserDao.xml针对的就是IUserDao的配置文件
导入mapper的约束
复制过来。
写mpper标签,标签上有一个namespace的属性
namespace就是xml文件的包名完整路径
然后配置查询,查询的标签是select。id是对应的方法的名称
id对应的就是dao内的方法名称
里面配置的就是查询语句
这样整个环境就搭建完成了。
总结