Creating basic example from returns 404 instead of mapped String


I’m unable to route requests to my Spring Boot application, even though I’ve tried the following:

The pom.xml and RestController class are provided below for reference.

  • My pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
       <relativePath/> <!-- lookup parent from repository -->
   <description>Rest Mobile Dev ICSD Api</description>






  • My RestController class

package Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

public class MainController {

    public String test()
        return "Hello World";

I’m unable to route requests to my Spring Boot application. I’m accessing it from localhost:8080/api and the MainController class is located within the Controller package.

I have tried the following solutions suggested on Stack Overflow, but none of them worked:

I have not encountered this issue before, as I have successfully run the same method with the same mapping on an older project.

The issue might be related to the package structure. The RestController class is located within the Controller package, but the package name is not defined in the @RequestMapping annotation. Try updating the annotation to @RequestMapping(value="/api", package="Controller").