Reputation: 5657
I'm following the Spring tutorial on the JetBrains website and when I try to build and run after adding the sayHello()
method, it tells me it cannot find symbol RequestParam
and GetMapping
:
@GetMapping("/hello")
public String sayHello(@RequestParam(value = "myName", defaultValue = "World") String name) {
return String.format("Hello %s!", name);
}
Error message:
Error:(14, 29) java: cannot find symbol
symbol: class RequestParam
location: class com.example.demo.DemoApplication
Error:(13, 6) java: cannot find symbol
symbol: class GetMapping
location: class com.example.demo.DemoApplication
Upvotes: 5
Views: 10368
Reputation: 399
Have you included spring-starter-web dependency?? If yes try to import those dependencies sometimes it is not imported by default you need to build project or click on import dependencies in IntelliJ.
Upvotes: 1