JerseyのリソースクラスをSpringコンポーネントとして定義をするときに、Springの @ComponentではなくJSR-330の @Name を使うと、@Transactional や @Aspect を使ったSpring AOPが効かない。
Jerseyの公式リファレンスによると、リソースクラスには以下のいずれかのアノテーションを使う必要があるとのこと。
@Component@Service@Controller@Repository
実装例
@Component // @NamedではAOPが効かない
public class SampleResource { ...
参考
- https://jersey.github.io/documentation/latest/spring.html
- https://github.com/jersey/jersey/issues/3328
- https://stackoverflow.com/questions/21104567/springjersey-transactional-annotation
- https://stackoverflow.com/questions/38133680/why-do-we-need-component-spring-annotation-for-jersey-resource-in-spring-boot-s