Play Framework 2.5.1 routing and dependency injection (for Java)
<p>I have this in my "routes" file:</p>

<pre><code>POST        /accounts/        controllers.AccountsController.createOneAccount
</code></pre>

<p>And in my AccoutsController.java:</p>

<pre><code>package controllers;

import com.google.inject.Inject;
import play.Application;
import play.mvc.Controller;
import play.mvc.Result;
import services.AccountService;
import java.io.IOException;

public class AccountsController extends Controller {
    @Inject
    private Application application;
    final String host = application.configuration().getString("db.default.host");
    final int port = application.configuration().getInt("db.default.port");
    final String dbName = application.configuration().getString("db.default.dbname");

    @Inject
    private AccountService accountService;
    public Result createOneAccount() throws IOException {
        return accountService.createOneAccount(request().body().asJson());
    }
}
</code></pre>

<p>This code is compiling fine, but in runtime I got error like this:</p>

<blockquote>
  <p>ProvisionException: Unable to provision, see the following errors: 1)
  Error injecting constructor, java.lang.NullPointerException   at
  controllers.AccountsController.(AccountsController.java:11)<br>
  while locating controllers.AccountsController
      for parameter 1 at router.Routes.(Routes.scala:28)   while locating router.Routes   while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
      for parameter 0 at play.api.http.JavaCompatibleHttpRequestHandler.(HttpRequestHandler.scala:200)
  while locating play.api.http.JavaCompatibleHttpRequestHandler   while
  locating play.api.http.HttpRequestHandler
      for parameter 4 at play.api.DefaultApplication.(Application.scala:221)   at
  play.api.DefaultApplication.class(Application.scala:221)   while
  locating play.api.DefaultApplication   while locating
  play.api.Application 1 error</p>
</blockquote>

<p>I can resolve this by adding @ to routes file:</p>

<pre><code>POST        /accounts/        @controllers.AccountsController.createOneAccount
</code></pre>

<p>but I am not sure about why I need to do this, and how to avoid the '@'. Please give some suggestions.</p>