spring - Where should @Service annotation be kept? Interface or Implementation? -


i'm developing application using spring. i'm required use @service annotation. i've servicei , serviceimpl such serviceimpl implements servicei. i'm confused here should keep @service annotation.

should annotate interface or implementation @service annotation? differences between these 2 approaches?

basically annotations @service, @repository, @component, etc. serve same purpose:

auto-detection when using annotation-based configuration , classpath scanning.

from experience using @service annotation on interfaces or abstract classes , annotations @component , @repository implementation. @component annotation using on classes serves basic purposes, simple spring beans, nothing more. @repository annotation using in dao layer, e.g. if have communicate database, have transactions, etc.

so suggest annotate interface @service , other layers depending on functionality.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -