Mybatis001-the first Mybatis program

1. Set up the environment
1. Connect to the MySql database and execute the following SQL statements:
Mybatis001-the first Mybatis program
2. Create a new ordinary Maven project and
Mybatis001-the first Mybatis program
Mybatis001-the first Mybatis program
delete the src directory to make this project called the parent project.
Mybatis001-the first Mybatis program
Import dependencies.
Mybatis001-the first Mybatis program
2. Create a module
. Create an ordinary Maven module under the parent project.
Mybatis001-the first Mybatis program
Mybatis001-the first Mybatis program
Write the
Mybatis001-the first Mybatis program
Mybatis001-the first Mybatis program
content of the mybatis core configuration file :
Mybatis001-the first Mybatis program
create a tool class
to create a package in the java directory, and the tool class
Mybatis001-the first Mybatis program
code is as follows:
Mybatis001-the first Mybatis program
three, write code
1, write entity class
Mybatis001-the first Mybatis program
2, write interface class

Mybatis001-the first Mybatis program
Mybatis001-the first Mybatis program
Create a UserMapper.xml
Mybatis001-the first Mybatis program
4.
Mybatis001-the first Mybatis program
Mybatis001-the first Mybatis program
If the test appears: org.apache.ibatis.binding.BindingException: Type interface com.kuang.dao.UserDao is not known to the MapperRegistry. Error, we need to configure the core configuration file mybatis-config.xml After registering each Mapper.xml in
Mybatis001-the first Mybatis program
this modification, a Caused by: java.io.IOException: Could not find resource com/kuang/dao/UserMapper.xml error will appear. This is the problem that the resource file cannot be exported in the maven project. The following code is added to the pom.xml of the parent project and module
Mybatis001-the first Mybatis program

Guess you like

Origin blog.51cto.com/12859164/2591668