Issue
I've read What is the difference between List.of and Arrays.asList?
What I'm not getting is why, after some dependency upgrades in my Maven pom.xml, suddenly all my
List.of(FLIGHT1_SPEND_AGG, FLIGHT1_IMPRESSIONS_AGG)
no longer compile. When I type List.
in IntelliJ, autocomplete only comes up with the class
member. I thought maybe I'm not importing java.util.List
? So explicitly specified it, but still:
I'm using Java 11, and I see the method exists here: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html.
Why can't I seem to use it? I must be doing something stupid...
Solution
It looks like you defined your Java version in your ide but not in your pom (at least not correctly)
Your pom needs to specify the maven-compiler-plugin and the source and target java versions.
The definition should look similar to this one:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
After the updates from maven, your IDE is using the Java version defined in your pom or using the default (which for some versions of the compiler plugin is as old as Java 5), overriding whatever you've set before.
Answered By - Nicktar
Answer Checked By - Candace Johnson (JavaFixing Volunteer)