Spring module

The spring support module help you to integrate Spring managed beans with a play application.

Enable the Spring module for the application

In the /conf/application.conf file, enable the Spring module by adding this line:

# The spring module

Define an application-context.xml registry

In the conf/ directory of the application you can then create a application-context.xml file and define some beans.

For example:

<?xml version="1.0" encoding="UTF-8"?>
    <bean id="test" class="utils.Test" />

Retrieve beans from application code

You can obtain bean instances from the application code, using the play.modules.spring.Spring helper.

public Application extends Controller {
    public static void index() {
        Test test = Spring.getBeanOfType(Test.class);

@javax.inject.Inject support

You can now use the @Inject annotation to automatically inject defined beans in your controllers, jobs and mailer.

It works on static fields defined in these artefact. For example to inject a PriceWatcher service defined in Spring to one of your controller, just do:

public class Application extends Controller {
    static PriceWatcher prices;
    public static void index() {
        prices.getAll(); // prices is defined here

Auto-reload should work as exepected.