SpringBoot开发报错集及对应原因总结

  1. 错误
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name ‘userInfoController’: Unsatisfied
    dependency expressed through field ‘userInfoService’; nested exception
    is org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name ‘userInfoService’: Unsatisfied
    dependency expressed through field ‘userInfoMapper’;nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userInfoMapper’ defined in file [E:\新桌面@立项-信息管理系统-1011工程\InfoPro\target\classes\com\nchu\infopro\dao\UserInfoMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [E:\新桌面@立项-信息管理系统-1011工程\InfoPro\target\classes\com\nchu\infopro\dao\UserInfoMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘file [E:\新桌面@立项-信息管理系统-1011工程\InfoPro\target\classes\com\nchu\infopro\dao\UserInfoMapper.xml]’. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.nchu.infopro.dao.UserInfoMapper.selectList. please check file [E:\新桌面@立项-信息管理系统-1011工程\InfoPro\target\classes\com\nchu\infopro\dao\UserInfoMapper.xml] and file [E:\新桌面@立项-信息管理系统-1011工程\InfoPro\target\classes\com\nchu\infopro\dao\UserInfoMapper.xml]
    造成原因:在UserInfoMapper.xml中对应方法与UserInfoMapper.java名称不符
  2. Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘123’ for key ‘account’
    ; Duplicate entry ‘123’ for key ‘account’; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘123’ for key ‘account’] with root cause
    造成原因:插入的account字段不允许重复
  3. .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errorsField error in object ‘user’ on field ‘age’: rejected value []; codes [typeMismatch.user.age,typeMismatch.age,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.age,age]; arguments []; default message [age]]; default message [Failed to convert property value of type ‘java.lang.String’ to re
    **造成原因:**前端axios的参数格式错误
  4. Optional int parameter ‘time’ is present but cannot be translated into a null value due to being decla
    今天在操作redis的时候报了这个错:Optional int parameter ‘time’ is present but cannot be translated into a null value due to being decla
    **造成原因:**传来的参数为空,则自动为null,但是接收对象是基本数据类型int所以无法赋值为null
  5. **前端:**This dependency was not found: * @/utils/validate in ./node_modules/cache-loader/dist/cjs.js??ref–13-0!./node_modules/babel-loader/lib!./node_modules/ cache-loader/dist/cjs.js??ref–1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Login
    **原因:**缺少了导入的包,查看对应import需要的包
  6. **前端:**Failed to resolve loader: sass-loader
    解决方法: 说明项目中没有 sass-loader依赖,由于sass-loader需要node-sass组件,所以我们需要安装的是两个组件:
  7. Syntax Error: TypeError: this.getOptions is not a function
    原因:一般是没有安装Sass但是却引用了Sass语法
    npm i node-sass@4.14.1 --save-dev
    npm i sass-loader@10.1.0 --save-dev
  8. Syntax Error: TypeError: this.getOptions is not a function
    原因:Sass直接安装,会自动安装为最新版本,会导致项目无法启动
    卸载新版
    npm uninstall --save sass-loader // 卸载
    npm uninstall --save node-sass // 卸载
    建议旧版本:
    npm install node-sass@4.14.1 --save-dev
    npm install sass-loader@8.0.0 --save-dev
  9. Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    数据库配置文件的url写错了,别的电脑项目mysql的端口是3307,自己的是3306,更改后就解决了

分别:

npm i node-sass -D

npm i sass-loader -D

注:这里吧这两个组件安装到开发依赖下,而不是生产依赖下。

  1. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that
    造成原因:在.xml中的SQL语句中,update中的**realName= #{realName},**最后多了个逗号“,”,去掉即可
UPDATE
            USER
        SET
            nickName= #{nickName},
            password= #{password},
            realName= #{realName},
        WHERE account= #{account}
  1. ElementUI中怎么input输入框怎么设置长度?
    方法
  2. 在设计数据表用户表的时候,用户表的主键应该设置为用户id而不应该设计成账号,虽然账号也是保持唯一的,但是账号在逻辑上是允许更改的,但是主码被修改是一件非常麻烦的事情。
    原因
    1. 在修该这张表的时候,还要先记录未修改前的主键,才能在找到这条记录的基础上,再去修改主键,处理很麻烦。
    1. 若这张表关联了其他表,一旦主码改变就会涉及级联修改其他表(主码在其他表充当外键)。
      *** 所以我明天得修改数据库用户表了
  1. 在mybatis的mapper.xml中,如何使用like的模糊查询
    方法
    使用 ${…} 代替 #{…}

    SELECT * FROM tableName WHERE name LIKE ‘%${text}%’;

  2. MySQL||唯一约束(Unique Key)和非空约束(NOT NULL)

  • 在创建表时设置唯一约束
    在定义完列之后直接使用 UNIQUE 关键字指定唯一约束,语法规则如下:
    <字段名> <数据类型> UNIQUE
    创建表时可以使用 NOT NULL 关键字设置非空约束,具体的语法规则如下:<字段名> <数据类型> NOT NULL;
  • 修改约束条件
    和默认值约束一样,修改约束条件的语法相似

ALTER TABLE <数据表名>
CHANGE COLUMN <字段名>
<字段名> <数据类型> NOT NULL;
ALTER TABLE <数据表名> ADD CONSTRAINT <唯一约束名> UNIQUE(<列名>);
例子:

ALTER TABLE USER
CHANGE COLUMN account
account VARCHAR(20) NOT NULL UNIQUE

  1. 以及怎么给属性设置级联修改
    给表设置外键
  • 修改约束条件
ALTER TABLE userrole ADD CONSTRAINT fk_userrole_roleId FOREIGN KEY (roleId) REFERENCES role(id)
  1. MySQL如何使用命令设置int类型字段自增长?
    创建:
    mysql>create table cc(id int auto_increment,name varchar(20),primary key(id));
    修改:
    mysql> alter table cc change id id int primary key auto_increment;
    注意:只有int类型且为primary key 才可以使用auto_increment.
  2. MySQL如何使用命令更改表的属性名称
    alter table exmaple_alter_test change sex sexs varchar(200);
  3. Invalid prop: type check failed for prop “model”. Expected Object, got Array ”
    当前是一个数组,数组中的元素才是对象
  4. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
    你有一个错误在你的SQL语法;检查与你的MySQL服务器版本相对应的手册,在第一行“附近使用正确的语法
  5. 分级分权限系统,如何根据账号信息确认登录页面显示的权限?
    1. 获取登录输入框中的账号和密码,在user表中查找,找到则登陆成功否则失败
    1. 登陆成功,则通过输入账号对应的userId在userRole表中找到对应的roleId
    1. 并且根据roleId在roleUrl表中找到其对应的urlId列表
    1. 并根据urlId列表
  1. js中indexOf(Char, [startIndex], [count]):返回指定字符在原字符串中的第一个匹配项的索引。可指定字符开始检索位置和指定长度的字符,若没有找到该字符,则返回 -1。也可以判断数组中是否包含某个值。

  2. router.beforeEach((to, from, next)三个参数的意思
    主要方法:
    to:进入到哪个路由去
    from:从哪个路由离开
    next:路由的控制参数,常用的有next(true)和next(false)

  3. cookie、session与token的真正区别

  4. redis的优点

  5. mysql8中创建表前怎么制定数据库

  6. 大型处理程序,在业务程序不需要管正确执行的逻辑,而只需要管理他不正确的逻辑,统一交给他的异常处理器执行。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值