I've been trying to create a simple hello world application with Java and SpringBoot in IntelliJ IDEA, but I get this error and I don't know how to solve it.
I get the error at the return. Java doesn't seem to know how to resolve the of
method that's in the public List<String> getHelloWorld
method.
package com.myname.SpringApp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class HelloWorldController {
@RequestMapping("api/hello-world")
@GetMapping
public List<String> getHelloWorld(){
return List.of("Hello", "World");
}
}
The overloaded List.of
methods were introduced in Java 9.
Since:
9
You must be compiling with an older version. Update to Java 9 or later. Here's how.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With