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="com.test.ws"> <context:exclude-filter type="aspectj" expression="com.test.ws.client.*" /> </context:component-scan>
Here we have defined a aspectj pointcut which will exclude all the classes in the sub-package.