title: Using SpringFrameWork @Async for methods that return void
body: <p>I'm using the Spring Boot framework as my backend.</p>
  
  <p>This is one of the calls I want to do asynchronously - it just saves a user into my mongoDB database:</p>
  
  <pre><code>@Async
  public Future&lt;Void&gt; saveUser(String userid) {
      User user = new User();
      user.setUserId(userid);
      return new AsyncResult&lt;Void&gt;(mongoTemplate.save(user));
  }
  </code></pre>
  
  <p>The method gives me an errors as <code>mongoTemplate.save(user)</code> returns a <code>void</code> value and not a <code>Void</code> object.</p>
  
  <p>I tried to change the method by substituting in <code>void</code> as follows but it does not work as <code>Future&lt;void&gt;</code> and <code>AsyncResult&lt;void&gt;</code> is not accepted:</p>
  
  <pre><code>@Async
  public Future&lt;void&gt; saveUser(String userid) {
      User user = new User();
      user.setUserId(userid);
      return new AsyncResult&lt;void&gt;(mongoTemplate.save(user));
  }
  </code></pre>
  
  <p>Is there anyway to run a method that returns void in an asynchronous way on Spring?</p>