Announcement Announcement Module
Collapse
No announcement yet.
Spring annotations and inheritance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring annotations and inheritance

    Hi

    I have a question regarding the spring annotations scope. Answers may save me some experimenting time
    If I use for example @Service, @Controller or @PreAuthorize annotations on a class or a method that is inherited by another class, will that annotation apply to the subclass / overriding methods?
    What about the other way around, if i use an annotation on a subclass or an overriding method, will it be applying to the superclass / method? (i expect not).

    Yuval

  • #2
    hi, i have the same question and find no clear answer from the web. Hope somebody or spring team can declare that.

    Comment


    • #3
      "me too"

      class Foo {
      @Transactional
      public void doSomething()
      { ... }
      }

      class Bar extends Foo{...}


      Is calling new Bar().doSomething() affected by the Transactional annotation in the super class??

      Comment

      Working...
      X