Java – how do I limit spring component scanning to files only in my war?
I'm using spring's component scan to find beans in my application
<context:component-scan base-package="com.myapp"/>
However, when the application is deployed on our staging server (JBoss 5 with a large number of applications deployed), the performance is much slower than that in development (also JBoss 5, but few applications) Component scanning takes a long time I suspect this is due to the larger classpath?
Is there an easy way for spring to find beans only in my war file? That is, WEB-INF / classes and WEB-INF / lib? Is there another solution?
Solution
Two tips;
>Try to use base package as much as possible (you can): you can provide multiple packages in the base package attribute, separated by commas. > Use filters; Check the document here. – You can specify the annotation to scan (for example, if you only use @ component), and you can also specify the regular expression that the class name must match