title: How to pass an argument to a Spring Boot REST Controller?
body: <p>I am trying to pass an argument to my @RESTController Spring Boot class.</p>
  
  <p>In the @POSTMapping method I want to use a method of a self defined Java class for processing the received body and returning a response.</p>
  
  <p>The Spring application is launched in Application.java. The Controller-Object seems to get created implicitly.</p>
  
  <p>I already tried adding a constructor to my RESTController class. But I couldn't find a way to call that constructor with an argument.</p>
  
  <pre><code>// Application.java
  public static void main (String[] args) {
      SpringApplication.run(Application.class, args);
  }
  </code></pre>
  
  <pre><code>//ConnectorService.java
  @RestController
  public class ConnectorService {
  
      private Solveable solver;
  
      public ConnectorService() {}
  
      public ConnectorService (Solveable solveable) {
          this.solver = solveable;
      }
  
      @CrossOrigin(origins = "http://localhost:3000")
      @PostMapping(path =  "/maze")
      public Solution Test(@RequestBody Test test) {
         return solver.solve(test);
      }
  
  }
  </code></pre>
  
  <p>Even though i could define a second constructor, i didn't find any way to call it with my Object.</p>