假设我有一个这样的模板类:
@Service
public class MyUIService {
public List<Books> getBooks(HttpServletRequest request, HttpServletResponse response) {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(Collections.singletonList(new MediaType("application","json")));
HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
ResponseEntity<List<Books>> responseEntity = restTemplate.exchange(
UriComponentsBuilder.fromHttpUrl(url).build().encode().toUri(),
HttpMethod.GET,
requestEntity,
new ParameterizedTypeReference<List<Books>>(){});
return responseEntity.getBody();
}
这个类位于h文件中并编译为静态库。
然后我有更多的模块,已经与这个静态库链接,我正在使用这个Foo类。
有没有办法在该模块中定义特定的打印功能? 或者我应该只在Foo类旁边定义具有特定实例的全局打印?