title: Spring Boot Rest service returns HTTP-404
body: <p>I've used Spring Boot for some time now but want to create a new application, starting with a simple REST service. No matter what I try, my service keeps returning a 404 error and I cannot find out why. I've found some similar sounding problems on the net but they almost always go about the Controller class not being in the right package, but that is NOT the case here. To rule out port problems I changed it from 8080->8901 (and several others) but to no avail. I also tried @ComponentScan which didn't work. Here are the files:</p>
  
  <p><strong>Application class:</strong></p>
  
  <pre><code>package nl.haba.demo;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.ApplicationContext;
  
  @SpringBootApplication
  public class DemoApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(DemoApplication.class, args);
      }
  }
  </code></pre>
  
  <p><strong>Controller class:</strong></p>
  
  <pre><code>package nl.haba.demo.controller;
  
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  @RestController
  public class GreetingService {
  
      @GetMapping("/greet")
      public ResponseEntity&lt;String&gt; greetPerson() {
          return ResponseEntity.ok().body("Hello, World");
      }
  }
  </code></pre>
  
  <p><strong>Application.yml</strong></p>
  
  <pre><code>server:
    port: 8901
  </code></pre>
  
  <p><strong>pom.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.3.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;nl.haba&lt;/groupId&gt;
      &lt;artifactId&gt;mydemo&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;mydemo&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>Spring startup log:</strong></p>
  
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::        (v2.3.1.RELEASE)
  
  2020-06-17 11:15:06.650  INFO 11251 --- [           main] n.h.demo.DemoApplication   : Starting DemoApplication on XXXXXXXXXXXXX with PID 11251 (/Users/xxxxxxxxxx/Projects/mydemo/target/classes started by xxxxxxxxxx in /Users/xxxxxxxxxx/Projects/mydemo)
  2020-06-17 11:15:06.653  INFO 11251 --- [           main] n.h.demo.DemoApplication   : No active profile set, falling back to default profiles: default
  2020-06-17 11:15:07.357  INFO 11251 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8901 (http)
  2020-06-17 11:15:07.365  INFO 11251 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  2020-06-17 11:15:07.366  INFO 11251 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.36]
  2020-06-17 11:15:07.442  INFO 11251 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
  2020-06-17 11:15:07.442  INFO 11251 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 748 ms
  2020-06-17 11:15:07.586  INFO 11251 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8901 (http) with context path ''
  2020-06-17 11:15:07.598  INFO 11251 --- [           main] n.h.demo.DemoApplication   : Started DemoApplication in 1.282 seconds (JVM running for 1.921)
  </code></pre>
  
  <p>When I use Postman to get the result on </p>
  
  <pre><code>GET http://localhost:8901/greet
  </code></pre>
  
  <p>it always returns with a 404 and I cannot figure out why. Curl did not work either.
  Can somebody please help me and tell me what i am missing here?</p>