Reputation: 2199
I have a code that is successfully compiled in Idea but fails to be compiled by maven clean package
.
The code is
import java.util.concurrent.*;
public class WebStatusMonitor {
private ConcurrentMap<String, Double> load = new ConcurrentHashMap<>();
public void handle(...) {
...
snapshot.add(String.format("cpu: %s", load.getOrDefault("cpu", 0.)));
...
}
And compilation fails with error
[ERROR] WebStatusMonitor.java:[121,66] cannot find symbol
symbol: method getOrDefault(java.lang.String,java.lang.Double)
location: variable load of type java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Double>
I have included what I use (actually everything was included automatically by Idea) and this code is even compiled successfully in Idea. Am I missing something?
Upvotes: 2
Views: 4330
Reputation: 139
It looks like your IDE uses java 8 and your maven is configured to use java 7.
The method does not exist in java 7 and does exist in java 8
Upvotes: 7