You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.4 KiB
49 lines
2.4 KiB
|
3 years ago
|
项目开发问题大集
|
||
|
|
|
||
|
|
> 这里收集着我平时所开发中用到的框架、插件所碰到的问题。如有人采用了这些,所碰到的问题可以来这里查找并解决。
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
问题1:
|
||
|
|
|
||
|
|

|
||
|
|
|
||
|
|
项目环境:
|
||
|
|
|
||
|
|
Spring boot 3.0 、Map Struct、Mybatis-plus、Spring Mvc
|
||
|
|
|
||
|
|
这里是在MapStruct类型转换中,参数因为超过了类型的范围所导致的问题。
|
||
|
|
|
||
|
|
因为int最大是21e而我这里的电话号码是110e的,才造成这样的问题。
|
||
|
|
|
||
|
|
1、int只有四个字节,而手机号是由11位十[进制](https://so.csdn.net/so/search?q=进制&spm=1001.2101.3001.7020)数组成的,即可知道手机号有五个字节,如果用int存储,则第五位溢出,被“吃掉了”制。
|
||
|
|
|
||
|
|
2、int的数据范围为-2147483648~2147483647[-2^31~2^31-1],是用于定义整数类型变量的标示符。
|
||
|
|
|
||
|
|
存储手知机号道用的类型:
|
||
|
|
|
||
|
|
1、使用数据库类型varchar2存储手机号,将手机号当作[字符串](https://so.csdn.net/so/search?q=字符串&spm=1001.2101.3001.7020)存储,后期取出便于显示。varchar2 数据类型指定一变长字符串,最大长度2000字节 。
|
||
|
|
|
||
|
|
2、在java等高级语言中,使用string存储手机号。
|
||
|
|
|
||
|
|
所以我在这里的解决方法就是直接给该字段定义为String类型。
|
||
|
|
|
||
|
|
问题2: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.NoSuchFieldError: iphone] with root cause
|
||
|
|
|
||
|
|
这里是dispatcherServlet的Handler的问题,由于我目前没有很深层次的学习这个Mvc的底层。对于所报的错误我是根据这篇文章解决的。
|
||
|
|
|
||
|
|
[(1条消息) Handler dispatch failed; nested exception is java.lang.NoSuchMethodError_handler dispatch failed nested_一碗谦谦粉的博客-CSDN博客](https://blog.csdn.net/weixin_45764765/article/details/118542951)
|
||
|
|
|
||
|
|
问题3:
|
||
|
|
|
||
|
|

|
||
|
|
|
||
|
|
这里所对应的是一个普通的问题,就是定义的userMapper是空的,这就是没有将这个mapper加载到容器中所导致的。在定义这个变量的头上添加一个@Resource
|
||
|
|
|
||
|
|
【题外话,不知道是idea的原因还是框架本身的版本原因,Spring 3.0 是不推荐使用@Autowired来进行自动注入Bean的,建议3.0的用户采用上面的方式来注入Bean。】
|
||
|
|
|
||
|
|
问题4:
|
||
|
|
|
||
|
|
|
||
|
|
|