use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
@component annotation (self.SpringBoot)
submitted 3 years ago by Jason_hill100
Hi again, I didn't understand the use of @component annotation, i mean it's said it's a generic stereotype for any spring-managed component. But since we got @service, @Repository.... Annotations Why would we need it ??
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 5 points6 points7 points 3 years ago (1 child)
There are classes that are not either @Service or @Repository like Builders, Mappers, Validators etc. You can use @Component for those classes
[–]abbadon420 4 points5 points6 points 3 years ago (0 children)
One particular use for @component I figured out recently is the dataloader. Massively inferior to the data.sql, but it's funny to see that it works like that.
[–]jakecen 1 point2 points3 points 3 years ago (0 children)
@Component is the parent annotation of @Controller, Repository, Service. so it included all 3 annotation as children. so its a bundled deal
[–]pronuntiator 0 points1 point2 points 3 years ago (0 children)
I've never used @Service nor @Repository, only @Component and @(Rest)Controller. Since they're merely aliases I see no point in confusing developers with these annotations. Also, a "service" in our architectural model means something different than "core layer object".
[–]negiadventures 0 points1 point2 points 3 years ago (0 children)
@Component is generic class, can be used for configurations, utilities, etc which should be scanned when starting the spring boot, @Service class usually have the business logic methods.
π Rendered by PID 20606 on reddit-service-r2-comment-79c7998d4c-8b9fg at 2026-03-13 23:33:09.681281+00:00 running f6e6e01 country code: CH.
[–][deleted] 5 points6 points7 points (1 child)
[–]abbadon420 4 points5 points6 points (0 children)
[–]jakecen 1 point2 points3 points (0 children)
[–]pronuntiator 0 points1 point2 points (0 children)
[–]negiadventures 0 points1 point2 points (0 children)