Spring / Intellij:原始使用参数化 class 'HttpEntity'
Spring / Intellij: Raw use of parameterized class 'HttpEntity'
我试图理解我的 Spring 代码中的警告。
我有一个 HttpEntity 被设置为我的 HttpHeaders,但是它被标记为 class.
的原始使用
我不确定这是为什么,也不知道如何纠正警告。我知道这只是一个警告,但我想摆脱它。
谁能解释一下删除它的原因和方法。
final HttpHeaders headers = new HttpHeaders();
final HttpEntity entity = new HttpEntity(headers);
private final static Logger logger = LoggerFactory.getLogger(GitHubService.class);
@Autowired
public GitHubService() {
headers.set("Authorization", gitHubAuthToken);
headers.set("Accept", "application/vnd.github.VERSION.raw");
}
我也收到了相同类型的警告
Warning:(44, 35) Unchecked call to 'HttpEntity(MultiValueMap<String, String>)' as a member of raw type 'org.springframework.http.HttpEntity'
非常感谢
您只需添加参数化类型:
final HttpEntity<String> entity = new HttyEntity<>(headers);
类型是实体的主体。可能是一个字符串,但取决于您如何使用它。
我试图理解我的 Spring 代码中的警告。
我有一个 HttpEntity 被设置为我的 HttpHeaders,但是它被标记为 class.
的原始使用我不确定这是为什么,也不知道如何纠正警告。我知道这只是一个警告,但我想摆脱它。
谁能解释一下删除它的原因和方法。
final HttpHeaders headers = new HttpHeaders();
final HttpEntity entity = new HttpEntity(headers);
private final static Logger logger = LoggerFactory.getLogger(GitHubService.class);
@Autowired
public GitHubService() {
headers.set("Authorization", gitHubAuthToken);
headers.set("Accept", "application/vnd.github.VERSION.raw");
}
我也收到了相同类型的警告
Warning:(44, 35) Unchecked call to 'HttpEntity(MultiValueMap<String, String>)' as a member of raw type 'org.springframework.http.HttpEntity'
非常感谢
您只需添加参数化类型:
final HttpEntity<String> entity = new HttyEntity<>(headers);
类型是实体的主体。可能是一个字符串,但取决于您如何使用它。