Spring-Data-Mongodb depedencies not picked by Play-Framework 2.4

后端 未结 1 453
醉酒成梦
醉酒成梦 2021-01-22 05:33

I am using play-framework 2.4 with Spring-Data-Mongodb. But when i compile the project the compile throw an error:

[error] /home/james/play-spring-data-mongodb/         


        
相关标签:
1条回答
  • 2021-01-22 06:24

    To use the repository feature in Spring Data, the life cycle has to be managed by Spring.

    Hence using it with Play 2.4 / 2.5, without adding Spring as a dependency is a problem because the default life cycle is managed by Guice.

    I figured out a way to create the Spring beans and transfer its life cycle management to Guice. Hence they can be injected anywhere in the project by Guice instead of Spring.

    For other components that don't have any Spring specific feature, they can be created normally and their life cycle will be managed by Guice.

    For other components, which are Spring specific and can only run inside a Spring container, they can also be injected in the project and their life cycle will managed by Guice.

    I modified the starter project included in Play 2.5 docs to demonstrate it.

    Please have a look at this repository.
    https://github.com/mohitsinha/play-java-spring-data-mongodb

    0 讨论(0)
提交回复
热议问题