Play framework 2.5.x and Spring Integration

1,016 views
Skip to first unread message

Santhosh Kumar

unread,
May 28, 2016, 12:53:57 PM5/28/16
to play-framework
I have been struggling to integrate Play 2.5.x with Spring. All the examples seen so far uses Global class which has been deprecated in 2.5.x Anybody has an example on how to integrate 2.5.x with Spring? 

Your help is much appreciated.

Santhosh.

Stone Horse

unread,
Jul 27, 2016, 10:16:23 PM7/27/16
to play-framework
I use this way to integrate with Spring as Play's document https://www.playframework.com/documentation/2.5.x/JavaDependencyInjection#Eager-bindings
app-context is placed in conf path

public class SpringContextModule extends AbstractModule {
   
@Override
    protected void configure() {
       
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("app-context.xml");
        bind
(BeanFactory.class).toInstance(applicationContext);
   
}
}

and for this Module doesn't in root(app/) path , add it in application.conf
play.modules {
 
# By default, Play will load any class called service.core.PersistRawModuletRawModule that is defined
  # in the root package (the "app" directory), or you can define them
  # explicitly below.
  # If there are any built-in modules that you want to disable, you can list them here.
  #enabled += my.application.service.core.PersistRawModuletRawModule
  enabled += "service.core.PersistRawModule"
  enabled += "service.core.PersistModule"
  enabled += "service.core.SpringContextModule"
  # If there are any built-in modules that you want to disable, you can list them here.
  #disabled += ""
}

finally , use spring context
public class UserAuthenticationHTTPBasicImp extends SupperEntityWithObjevtPersist<User>implements UserAuthenticationService {

   
private BeanFactory beanFactory;
   
private TokenService tokenService;

   
@Inject
    public void setup(BeanFactory beanFactory,TokenService tokenService) {
       
this.tokenService = tokenService;
       
this.beanFactory = beanFactory;
   
}

I only use JMSTemplate with spring , so I placed this beanfactory at here . you could use it as normal Spring applications.

在 2016年5月29日星期日 UTC+8上午12:53:57,Santhosh Kumar写道:

Eva M

unread,
Jul 31, 2016, 8:37:08 PM7/31/16
to play-framework
Hi Santhosh,

I know it's been a while since your question was asked, but maybe you will find some help in the following example (like you, I have struggled and found a way to do things with Spring DI in Play 2.5.x)

Greg Methvin

unread,
Aug 1, 2016, 3:15:09 AM8/1/16
to play-framework
You may want to check out this project that was recently released: https://github.com/remithieblin/play-spring-loader. It's an actual Spring application loader, so you can use Spring for both Play internal components and your application components. I would recommend that strategy over using two different systems for DI.

Greg

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/c31599da-2a40-41fa-b4a6-82c163234231%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Senior Software Engineer

Erika Quillupangui

unread,
May 27, 2017, 2:57:54 PM5/27/17
to Play Framework


Where can download play 2.5.x

Greg Methvin

unread,
May 29, 2017, 12:07:19 AM5/29/17
to play-framework
I would recommend downloading a starter project at https://www.playframework.com/download

On Fri, May 26, 2017 at 3:53 PM, Erika Quillupangui <erika...@gmail.com> wrote:


Where can download play 2.5.x

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2b0f0469-596f-4f29-b803-56c66eea4465%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Manabu Tokunaga

unread,
Sep 23, 2017, 9:51:16 AM9/23/17
to Play Framework
Just for a record. There is now one more possibility,


Which depends on this;

Reply all
Reply to author
Forward
0 new messages