1 .要防止依赖重复导入,不然会报错
There was an unexpected error (type=Not Found, status=404).
No message available
2.spring文件要扫描xml文件,要在配置文件里面,添加路径,页面也是一样,要给顶相对的地址,才能扫描到。
thymeleaf:
prefix: classpath:/templates/
3.mybaits-plus里面,数据库对应的实体类里面,用的是驼峰,尽量不要用下划线的模式,但是数据库中要用,如果真的要用,要把配置里面的
# 驼峰下划线转换
map-underscore-to-camel-case: true
中的true改为false
默认就是true,需手动添加配置
ps:mybatis默认是flase
4.使用mybaits连接数据库时,mapper层扫不到,报错如下
Invalid bound statement (not found): com.rjgc.management.Dao.checklogin_mapper.showall
检查如下: 有没有在启动中手动配置扫描路径:
@MapperScan(“com.rjgc.management.Dao”)//扫描Dao层(mapper层)
有没有在mapper层里添加@mapper的注解
以上做一个就好
最终还是没有解决问题,发现没有在配置文件中添加mybatis配置路径,如下:
mybatis.mapper-locations=classpath:mapping/*.xml (配置文件为application.properties时)
mybatis:
mapper-locations: classpath:mapper/*_mapper.xml (配置文件为application.yml时)
5.用IDEA编写前端页面的时候发现不能加载css和js文件
使用的是thymeleaf模版
解决方式:
1.检查在配置文件(pom文件)中是否导入thymeleaf的启动包
org.springframework.boot
spring-boot-starter-thymeleaf
2.检查路径
src
└─main
├─java
└─resources
├─static
│ ├─css
│ ├─img
│ └─js
│ └─test.js
└─templates
3.springboot的机制问题:
明明路径加载对了却显示不出来,带着疑惑在网上查找了许多文档,最后发现是由于SpringBoot机制问题,引用css或js文件的时候需先将文件放在static文件夹下面然后引用的时候不要将static写上。