@JsonIgnore
发表于|更新于
|浏览量:
沙漠之所以美丽,是因为在某个不知道的地方藏有一口井。——《小王子》
在项目开发中,有时会遇到一些字段并不需要或者不能返回给前端的时候(例如密码等)
则可以在对应的属性上加com.fasterxml.jackson.annotation.JsonIgnore注解

这样的话,在返回的时候就不会被序列化了
不过注意,如果加了@JsonIgnore注解,在接收参数时同样不会被序列化

相关推荐
2024-01-05
xxl-job restful api
谁若与集体脱离,谁的命运就要悲哀。——奥斯特洛夫斯基 昨天对接了xxl-job的restful api,发现其没有提供查询job信息的api,于是自己拓展 在原先com.xxl.job.admin.controller.JobApiController#api添加 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/** * api * * @param uri * @param data * @return */@RequestMapping("/{uri}")@ResponseBody@PermissionLimit(limit=false)public ReturnT<?> api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = fals...
2021-01-25
BindingException:Invalid bound statement not found
性格左右命运,气度影响格局。——余世雅博士 转,原文 解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件,在pom.xml中加入一下代码可以解决: 123456789101112131415161718<build> <resources> <!-- maven项目中src源代码下的xml等资源文件编译进classes文件夹, 注意:如果没有这个,它会自动搜索resources下是否有mapper.xml文件, 如果没有就会报org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pe...
2023-11-13
webflux中操作符调试
生命不息,奋斗不止。——卡莱尔 分享一个小技巧,在webflux开发中,我们可以在主启动类上加这么一行代码: 1Hooks.onOperatorDebug(); 这行代码的用处是注册一个回调函数,可以打印操作符信息,举个例子: 12345678910111213141516import reactor.core.publisher.Flux;import reactor.core.publisher.Hooks;public class DebugExample { public static void main(String[] args) { Hooks.onOperatorDebug(); // 启用操作符调试 Flux<Integer> flux = Flux.just(1, 2, 3, 4) .map(i -> i / 0); // 这里会触发除以零的异常 flux.subscribe( value -> Syst...
2023-06-20
写一个基于lambda的copyProperties(二)
谨慎比大胆要有力量的多。——雨果 书接上文写一个基于lambda的copyProperties 今天继续整一个支持其他类型的 123456789101112131415161718@Datapublic static class User { private String name;}@Datapublic static class Person { private String name;}@Testvoid testCopyProperties() { User source = new User() {{ setName("test"); }}; Person target = BeanHelper.copyProperties(source, Person.class); Assertions.assertEquals(source.getName(), target.getName());} 源码如下: 123456789101...
2020-12-21
@Scheduled的使用
人之患在好为人师。——《孟子》 今天朋友问我定时任务怎么创建,让我们一起重温复习一下吧~ 首先需要在启动类上加@EnableScheduling注解(组件上也可以加) 然后在需要定时的方法上加上@Scheduled注解 1234567891011121314151617181920212223242526package com.ruben.task;import lombok.extern.slf4j.Slf4j;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;/** * @ClassName: LogTask * @Description: 我还没有写描述 * @Date: 2020/12/21 0021 20:11 * * * @author: <achao1441470436@gmail.com> * @version: 1.0 * @since: JDK 1.8 */@Slf4j@Comp...
2020-07-28
jenkins配置之Tomcat篇
配置Tomcat下载链接:/img/oss/picGo/apache-tomcat-8.5.57.tar.gz 然后上传到服务器,解压 12345tar -zxvf apache-tomcat-8.5.57.tar.gz #创建目录mkdir /opt/tomcat#移动文件mv apache-tomcat-8.5.57/* /opt/tomcat/ 检测8080端口是否被占用 12345netstat -ntpl#查看指定端口netstat -lnp|grep 8080#解除占用kill -9 [端口号] 1234#运行tomcat8/opt/tomcat/bin/startup.sh#查看日志tail -f /opt/tomcat/logs/catalina.out 访问 注意。。。我这里是改了Gitlab的端口,否则会导致端口占用,要么tomcat启动不了,要么Gitlab502 123456789101112131415161718192021#更改gitlab配置文件vim /etc/gitlab/gitlab.rb...
