In this case you will get that error, because @SlingServlet have a property “generateComponent” by default it’s value is “true” so ideally you don’t provide the @Component annotation.
How to Resolve this issue –
There are two ways to resolve this issue –
Remove @Component annotation while creating Sling Servlet.
The issue with first solution are –
We are not able to activate this Sling Servlet immediately, It is totally dependent on Felix implementation when it will activate this Sling Servlet. i.e. it may or may not be in active state after deploying the package.
We are not able to use immediate, enabled metatype & other properties provided by @Component