Dmitry Zagorski
Dmitry Zagorski

Reputation: 29

@ComponentScan in Spring (not Boot) doesn't scans subpackages

My project is situated in package home.bank_application. There are a lot of subpackages, such as 'controller', 'dao', 'service', 'config' etc... When I annotated my WebConfigClass as @ComponentScan(basePackages = "home.bank_application") my subpackages aren't scaned.

When I annotated my WebConfigClass as @ComponentScan(basePackages = {"home.bank_application.controller", "home.bank_application.dao","home.bank_application.service", "home.bank_application.config"}), all these packages are scaned fine. But when I annotated my WebConfigClass as @ComponentScan(basePackages = "home.bank_application") my subpackages aren't scaned. What is the problem?

Upvotes: 2

Views: 279

Answers (1)

Dmitry Zagorski
Dmitry Zagorski

Reputation: 29

I found the solution of this problem. @ComponentScan(basePackages = "home.bank_application") and @ComponentScan(basePackages = "home.bank_application.*") NOT the same things. All problem was in * in the end of path!!!

Upvotes: 0

Related Questions