How to exclude a sub package from Spring component scanning?

Suppose you are using Spring component scanning and you don’t want to scan classes in the sub-package you should use <context:exclude-filter> subtag of <context:component-scan> tag as shown below

<context:component-scan base-package="">
	<context:exclude-filter type="aspectj" expression="*" />

Here we have defined a aspectj pointcut which will exclude all the classes in the sub-package.