Spring boot 为什么在Spring boot中将access\u令牌更改为accessToken
我的波乔 公共类VerifyLoginRepdto{Spring boot 为什么在Spring boot中将access\u令牌更改为accessToken,spring-boot,Spring Boot,我的波乔 公共类VerifyLoginRepdto{ private String access_token;//NOSONAR private String refresh_token;//NOSONAR private String edit_by_user;//NOSONAR private String scope;//NOSONAR private String token_type;//NOSONAR private String expires_in;//NOSONAR } 控制
private String access_token;//NOSONAR
private String refresh_token;//NOSONAR
private String edit_by_user;//NOSONAR
private String scope;//NOSONAR
private String token_type;//NOSONAR
private String expires_in;//NOSONAR
}
控制器文件
@RequestMapping(value = "/login", method = RequestMethod.POST)
VerifyLoginRespDto verifyLogin(@RequestBody @Valid VerifyLoginDto verifyLogin) {
// some code
}
但我的回答是这样的
{
"scope": "basic,",
"refreshToken": "c2a4f22b-6446-49ad-8cc9-ef1a844d6cbb",
"tokenType": "bearer",
"expiresIn": "2591892",
"accessToken": "54b3f27b-ad5c-4d7b-ae5d-07f56f5f2f42",
"editByUser": "0"
}
为什么密钥访问令牌在Spring boot中更改为accessToken?因为用于POST请求的类是VerifyLoginIndo,而此POST请求的响应类型是VerifyLoginRepdto VerifyLoginRespDto必须具有映射到access\u令牌的属性accessToken
注意:请不要像此私有字符串访问令牌一样使用属性名称;。您应该遵循驼峰案例,因为java和Spring非常敏感地遵循这一点。所有bean将仅根据camel case创建。因为我的用户Jackson将通过getter方法输出json。我的方法nama是getAccessToken,所以当我使用gson时,错误就消失了