For this recipe, we will explore how to integrate the popular Spring Framework with a Play application. We will use Spring for bean instantiation and injection using Play controllers and service classes.
For Java, we need to take the following steps:
Run the
foo_java
application with Hot-Reloading enabled:activator "~run"
Declare Spring as a project dependency in
build.sbt
:"org.springframework" % "spring-context" % "3.2.2.RELEASE", "org.springframework" % "spring-aop" % "3.2.2.RELEASE", "org.springframework" % "spring-expression" % "3.2.2.RELEASE"
Create a new admin controller in
foo_java/app/controllers/AdminController.java
with the following code:package controllers; import play.*; import play.mvc.*; import org.springframework.beans.factory.annotation.Autowired; import services.AdminService; @org.springframework.stereotype.Controller public class AdminController { @Autowired private AdminService...