title: Spring MVC can't find mappings
body: <p>I am trying to get my OrderController to work, but MVC can't seem to find it. Does anyone know why this happens?</p>
  <p>Initializer class. The getServletMapping method keeps notifying me about Not annotated method overrides method annotated with @NonNullApi</p>
  <pre><code>package configs;
  
  import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
  
  public class Initializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class[0];
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return new Class[]{Config.class};
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { &quot;/api/*&quot; };
      }
  }
  </code></pre>
  <p>The config class.</p>
  <pre><code>package configs;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.core.env.Environment;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.jdbc.core.JdbcTemplate;
  import org.springframework.jdbc.datasource.DriverManagerDataSource;
  import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
  import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  
  import javax.sql.DataSource;
  
  @EnableWebMvc
  @Configuration
  @ComponentScan(basePackages = {&quot;model&quot;})
  @PropertySource(&quot;classpath:/application.properties&quot;)
  public class Config {
  
      @Bean
      public JdbcTemplate getTemplate(DataSource ds) {
          return new JdbcTemplate(ds);
      }
  
      @Bean
      public DataSource dataSource(Environment env) {
          DriverManagerDataSource ds = new DriverManagerDataSource();
          ds.setDriverClassName(&quot;org.hsqldb.jdbcDriver&quot;);
          ds.setUrl(env.getProperty(&quot;hsql.url&quot;));
  
          var populator = new ResourceDatabasePopulator(
                  new ClassPathResource(&quot;schema.sql&quot;),
                  new ClassPathResource(&quot;data.sql&quot;)
          );
  
          DatabasePopulatorUtils.execute(populator, ds);
  
          return ds;
      }
  }
  
  </code></pre>
  <p>Then the controller.</p>
  <pre><code>package controllers;
  
  import model.Order;
  import model.OrderDAO;
  
  import org.springframework.http.HttpStatus;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @RestController
  public class OrderController {
  
      private OrderDAO orderdao;
  
      public OrderController(OrderDAO orderDAO) {
          this.orderdao = orderDAO;
      }
  
      @PostMapping(&quot;orders&quot;)
      @ResponseStatus(HttpStatus.CREATED)
      public Order saveOrder(@RequestBody Order order) {
          return orderdao.addOrder(order);
      }
  
      @GetMapping(&quot;orders/{id}&quot;)
      public Order getOrderById(@PathVariable Long id) {
          return orderdao.getOrderById(id);
      }
  
      @GetMapping(&quot;orders&quot;)
      public List&lt;Order&gt; getOrders() {
          return orderdao.getAllOrders();
      }
  
      @DeleteMapping(&quot;orders/{id}&quot;)
      public void deleteOrderById(@PathVariable Long id) {
          orderdao.deleteOrderById(id);
      }
  }
  </code></pre>
  <p>Everything seems fine, I can't find the issue.</p>