Skip to content

Spring RestTemplate getForObject getting 404

I’m trying to make a get request to an Api Rest but I’m always getting 404, nevertheless if try copying queryUrl in a browser or postMan it works perfectly. restTemplate.getForObject(queryUrl, entity ,Integer.class); I’ve also tried this: HttpHeaders httpHeaders = new HttpHeaders(); httpHead…

docker stats shows zero memory usage even for running containers

I have two containers ran by Docker Swarm: Host OS is Debian Jessie. There are JVM applications in both containers. Why does docker stats show zero memory usage? Should I configure my Java apps somehow to be able to see memory usage in docker stats? Is there some other way to check memory usage? Answer It is …

clear all values of hashmap except two key/value pair

I have a HashMap with hundred of key/value pairs. Now I have to delete all key/values except 2 key/value. I have use this way : But java 8 introduced removeIf() for these kind of condition. How can I solve this problem with removeIf() method ? Answer You’ll need to it like this : It will iterate over th…

Query-by-example skip primitives?

Spring supports creating queries by examples of the object to look for. Like: Problem: if the @Entity has primitive fields, then their default value will actually be used for creating the query. The example above will result in: SELECT * from persons where lastname := ‘Smith’ and age := 0 In my ex…