进坑

  1. mybatis
    1. 导入依赖时报错
    2. mybatis jar包导入失败爆红
    3. mapper路径填写错误 The error may exist in com/guol/mapper/UserMapper.xml
    4. 打印输出时输出地址
    5. main函数加载失败

mybatis

导入依赖时报错

file -> settings -> maven -> Maven home directory选项 -> 参数改为自己maven的本地地址

mybatis jar包导入失败爆红

·报错的样子是这样的话

·可以通过file -> settings -> maven ->

mapper路径填写错误 The error may exist in com/guol/mapper/UserMapper.xml

报错:

发生这个错误可能时核心配置文件的中关于Mapper的.xml文件路径填写错误

打印输出时输出地址

输出结果

可能是因为实体类中缺少toString方法,在实体类中添加toString方法

1
2
3
4
5
6
7
public String toString() {
return "Account{" +
"id=" + id +
", name='" + name + '\'' +
", money=" + pwd +
'}';
}
### mybatis 操作数据运行成功但数据库中的数据没有发生变化 可能是没有提交事务,在所有操作之后释放资源之前添加提交事务的语句
1
sqlSession.commit();

main函数加载失败

在父项目的pom.xml的标签里添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 jaytp@qq.com

×

喜欢就点赞,疼爱就打赏