3

I using annotation configuration for spring context like

<context:annotation-config/>
<context:component-scan base-package="example"/>

But project is fairly large and scanning for both components have much time (10 s for one scan). Can I configure this in only one scan, that is proceeded in ?

2 Answers 2

3

I think the base-package value can actually contain multiple packages. Try specifying something like:

<context:component-scan base-package="example.package.one,example.package.two"/>

Where you are explicitly specifying only the packages you need.

Sign up to request clarification or add additional context in comments.

Comments

2

10s is not much time at all, because it is performed only once - on startup. You can limit the scanned packages by specifying more detailed package names (not just example).

You mention "both" - if you have only 2 spring beans, just list them with <bean> in the XML and drop the component scan.

3 Comments

10s it's time of one scaning, it's fairly large and grow up with project evolution
@user298061 how many spring beans do you have? Are you sure it is only for scanning, or for initialization of all the beans?
They are several hundred, but 10 s it's scaning only excluding bean registation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.