毕业设计爬坑记录

仅以此博客来记录做毕设过程中遇到的坑

后端

1.

报错

//Field XXX in XXXX required a bean of type XXXX that could not be found

Field udao in com.zyc.service.InitServiceImpl required a bean of type 'com.zyc.mapper.UserMapper' that could not be found.

但是检查XXX发现@Autowired自动注入并没有问题,mapper也是mybatisgen自动生成的,也没有问题。

发现原因

是扫描的包路径写错了,mapper没有扫描到(之前是复制粘贴上一个项目的哈哈哈)

解决办法

mapperScannerConfigurer.setBasePackage("com.zyc.mapper");

将扫描mapper路径改对即可

——————————————————————————   ————————————   —————

2.

报错

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary

初步判定是mysql驱动的问题,但是我项目是用的springboot,按道理不应该出问题

发现原因

经过百度发现,有许多人遇到一模一样的错误。网友给出的原因是最新的mysql驱动名称变了

以前的是

jdbc.driverClassName=com.mysql.jdbc.Driver

现在的是

jdbc.driverClassName=com.mysql.cj.jdbc.Driver

解决办法

改正配置中的名称即可

——————————————————————————   ————————————   —————

3.

报错

Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

发现原因

经过百度,有许多人遇到一模一样的错误。网友给出的原因是这是在使用MySQL 8.0以上版本(MySQL连接驱动和版本都是8.0以上)的时候出现的问题错误

解决办法

我们需要在访问数据库的Url后面加上以下的语句即可:

?serverTimezone=GMT%2B8

比如我配置中原来是

url: jdbc:mysql://127.0.0.1:3306/loan?useUnicode=true&characterEncoding=utf-8

改成

url: jdbc:mysql://127.0.0.1:3306/loan?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8

——————————————————————————   ————————————   —————

4.

用redis时,model层必须实例化

例如

public class User implements Serializable{}

——————————————————————————   ————————————   —————

5.

没有报错,但是当java程序往redis中存数时,redis-cli(客户端)中查不到数字

发现原因

尝试了一下java程序可以从redis中取出数,又尝试了一下关闭redis服务器,java会报错找不到redis。

所以应该是java和redis客户端没有查询同一个redis数据库,并且java是可以成功往redis中存值的

在redis配置中

redis:
            host: 127.0.0.1
            port: 6379
            pass:
            maxIdle: 3000
            maxWait: 1000
            testOnBorrow: true
            database: 12 #    换数据库

那个database就是用哪个数据库,这里用的是12,而在redis客户端中,登陆redis,默认选择了数据库0,如果需要切换到其它数据库使用select 索引值,如select 1表示切换到索引值为1的数据库

解决方法

在redis-cli中select 12,使数据库和spring的redis配置中database后的数字相同

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章