Documentation

You are viewing the documentation for Play 1. The documentation for Play 2 is here.

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
module.spring=${play.path}/modules/spring

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"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springsource.org/dtd/spring-beans-2.0.dtd">
<beans>
    
    <bean id="test" class="utils.Test" />
    
</beans>

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

Not implemented yet.