Comments (6)
把isUserFollowing字段的get方法名改成isUserFollowing()就可以了,hutool的copy方法的get方法匹配is开头的布尔值字段时,是使用下面这几种格式匹配的
from hutool.
这个方法名称是使用IDEA自动生成的。 按照你的这个解决办法 我如果后面使用到了 boolean 类型 全都需要自己手动添加 get set 方法?
from hutool.
这个方法名称是使用IDEA自动生成的。按照你的这个解决办法 我如果后面使用到了 boolean 类型 全都需要自己手动添加 get set 方法?
首先,是不太建议使用is开头去命名布尔型变量,其次IDEA自动生成的get方法是可以调整模板的
from hutool.
这样的话,团队的所有人都去进行修改,为什么不按照流行的 spring
这类框架来进行拷贝呢? 是代码历史原因,还是出于什么原因呢?
from hutool.
这样的话,团队的所有人都去进行修改,为什么不按照流行的
spring
这类框架来进行拷贝呢? 是代码历史原因,还是出于什么原因呢?
主要是is开头的布尔型变量本身就是不太规范的写法,JSON 序列化也可能会出现问题
from hutool.
@iszhangsc 这里不匹配是因为Hutool存在一个字段和getter匹配检查的功能,这个Spring没有。
在Spring中,只读取getter和setter方法,而不去判断字段,你可以试下,isUserFollowing
换成任意名字,Spring也是照样可以的。
如果只判断方法而不去匹配字段,就存在误判问题。比如你自定义了一个方法,叫做getXXXX,但是并没有对应字段,那这个方法要不要读取呢?Hutool的策略是不读取。
Spring的方法存在第二个问题,就是假设你有两个字段:isUserFollowing
和userFollowing
那你的getter方法该如何定义呢?因此,为了解决这些问题,Hutool专门做了字段匹配功能,来避免这些问题。
欢迎进一步讨论。
from hutool.
Related Issues (20)
- ### 版本情况 HOT 1
- hutool.cn首页无法打开 HOT 4
- 能否把CharSequenceUtil里的方法在StrUtil里重写以规避sonar检测 HOT 4
- DateUtil.endOfDay的一个奇怪问题 HOT 1
- 6.0.0版本 BeanUtil会导致Metaspace溢出 HOT 8
- HttpUtil post 响应结果乱码问题 HOT 1
- 在Windows环境获取指定层级的父路径错误`FileUtil.getParent` HOT 1
- cn.hutool.core.exceptions.UtilException: IllegalAccess for class org.springframework.amqp.utils.SerializationUtils.TRUST_ALL HOT 1
- 是否可以提供简单点的AES加解密方法 HOT 1
- 关于JSONUtil中字符串问题 HOT 1
- 关于JSONUtil序列化Optinal为空字典的问题,有办法可以获取到optional的值吗 HOT 2
- 有没有把inputstream下载到浏览器文件的方法 HOT 1
- 类似jackson的@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 的注解 HOT 1
- cn.hutool.json.JSONUtil#toBean(java.lang.String, java.lang.Class<T>) 字符串转Bean,@Alias(cn.hutool.core.annotation.Alias)别名注解解析嵌套多层结构数据异常!!! HOT 3
- cron 错误 栈溢出 HOT 1
- LRU Cache 并发get HOT 1
- outlook 邮件发送是否支持 Oath2 认证方式 HOT 2
- BeanUtil.copyProperties导致积压class不回收 HOT 11
- 打jar包后fileutils的exist方法找不到resource目录下的文件下,怎么解决呢 HOT 1
- GraphicsUtil 接口变化,导致不兼容旧版本 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hutool.