一些小坑

一、使用jackson反序列化时存在多余字段

Unrecognized field "xxx" (……), not marked as ignorable (5 known properties: "xxxxxxxxx",

反序列化字段未匹配上,忽略掉这些字段:

 
  
public class JsonUtil {

public static final ObjectMapper objectMapper;

static {
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

}

二、swagger配置开发环境

@Profile("dev")  //指定只可以在dev环境看到接口doc
@Configuration
@EnableSwagger2
@Profile("dev")
@ComponentScan("com.xxx.xxx.controller")
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xxx.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfoBuilder().title("Service APIs")
                .description("Service APIs")
                .license("xxx")
                .licenseUrl("http://www.xxx.com")
                .version("1.0")
                .build();

        return apiInfo;
    }
}

三、modelmapper的严格匹配

    private ModelMapper mapper;

    /**
     * init mapper
     */
    public DemoController() {
        this.mapper = new ModelMapper();
        this.mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    }

四、编译错误

Error:java: Compilation failed: internal java compiler error

五、git仓库迁移

git仓库迁移,需要重新映射项目地址,不删本地库,修改config即可:

把如下2个文件中的git仓库IP改成新IP地址就行,不必重新拉:

  • C:\Users\你的用户名\.ssh\config
  • 项目目录\.git\config

如果有多个项目目录,就在每个项目目录里改。
注意改config时使用vi或vim来修改(windows下不能用notepad来修改)

改完了 git pull 或 git push 即可,如果失败,需要执行下命令:(本地分支 local_branch_name 和 远程分支 remote_branch_name 建立联系)

git branch --set-upstream <local_branch_name> origin/<remote_branch_name>

六、notepad编辑问题

用windows系统自带的notepad.exe编辑csv文件,另存为UTF-8格式后,CSVReader读取的第一行列名左上角带符号

解决办法参考:pandas读取txt文件第一行列名困扰我许久的'点'

七、HttpServletRequest序列化报错

        HttpServletRequest request = new Request();
        JSON.toJSONString(request);

序列化报错:

Caused by: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
    at org.apache.catalina.connector.Request.getAsyncContext(Request.java:1742)

八、Object 和 Map序列化

 

转载于:https://www.cnblogs.com/mr-yang-localhost/p/7709759.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值