How to use Jersey 2 with Spring IoC container

前端 未结 3 1274
遇见更好的自我
遇见更好的自我 2020-12-28 19:37

What is the best way to enable injection of spring beans into Jersey 2? Jersey seems to not support this natively.

What is needed to wire the 2 frameworks together?

3条回答
  •  被撕碎了的回忆
    2020-12-28 20:16

    You should be able to annotate jersey components and then use annotations to inject the beans.

    @Service //(or @Component)
    public class MyJerseyService {
    
        @Autowired
        private MyObj mySpringBean
    
    }
    

提交回复
热议问题