Shadi Shadi - 8 months ago 79
Java Question

using ComponentScan or context:component-scan with only one class

I'm maintaing a project with two set of main packages, the project is using spring and spring mvc, one of these packages contains several controllers and is scanned using xml (context:component-scan), the problem is that there is a single class in the other package(not scanned), I need this class to be scanned but only this class and nothing else in the package, I can't change its package now since it would be too risky now.

so is there a way to do this using annotation or xml ?


Simply add is as a bean to your context e.g.

<bean class="my.package.MyClass" />