Comparative following code can know the relationship between the AccountRepository and AccountRepository.xml.
------------------------接口------------------------
public interface AccountRepository {
public int save(Account account);//插入一条记录
public int update(Account account);//更新一条记录
public int deleteById(int id); //删除
public List<Account> findAll(); //查询
public Account findById(int id);//查询
}
-------------------------mapper---------------------
<!--namespace中放入接口路径-->
<mapper namespace="com.lmybatis.repository.AccountRepository">
<insert id="save" parameterType="com.lmybatis.entity.Account">
insert into t_account(username,password,age) values(#{username},#{password},#{age})
</insert>
<delete id="deleteById" parameterType="int">
delete from t_account where id = #{id}
</delete>
<update id="update" parameterType="com.lmybatis.entity.Account">
update t_account set username=#{username},password=#{password},age=#{age} where id=#{id}
</update>
<select id="findAll" resultType="com.lmybatis.entity.Account">
select * from t_account
</select>
<select id="findById" parameterType="int" resultType="com.lmybatis.entity.Account">
select * from t_account where id=#{id}
</select>
</mapper>
<!--记住!要在config.xml中配置该xml文件-->
Note: 1 in config.xml to configure the xml files; 2 to be addressed by adding the following description in pom.xml, or seek only the default static file folder, not access the custom in other files... xml file
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>