Questions regarding using `@ComponentScan` to detect Spring managed components
Questions tagged [component-scan]
129 questions
1
vote
0 answers
Scanning for Annotations in SpringApplication's scanBasePackage={...}
I found various was of scanning my packages for annotations, like the one here:
Java annotation scanning with spring
https://stackoverflow.com/a/12021972/2056452
...
What those answers have in common, is that I need to pass a string, defining the…

derM - not here for BOT dreams
- 13,081
- 4
- 49
- 89
1
vote
3 answers
SpringBoot multiple module Consider defining a bean of type in your configuration
I have a multiple modules Spring-boot application, I have two submodules:
spring-boot-rest-api-todo-list
persistence
that are organized like this:
persistence module

medkhelifi
- 1,071
- 3
- 17
- 35
1
vote
1 answer
Spring mvc hide one package from others
As it can be seen in picutre, my ComponentScan is set to whole project. But somehow 'config' package doesn't see any other package and vice versa.
If I run my project, i get an error on startup that No qualifying bean of type…

Ars
- 591
- 1
- 4
- 19
1
vote
2 answers
SpringBoot do not scan named packages
I build a demo module based on SpringBoot , and include server and client application.
The path like:
├── test
│ ├── client
│ │ ├── DemoController.java
│ │ └── ClientApplication.java
│ ├── server
│ │ └── ServerApplication.java
I…

ajianzheng
- 283
- 2
- 3
- 11
1
vote
1 answer
org.sf.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type X available
I'm trying to setup a simple project with a user repository in Spring Boot with Hibernate as JPA, I tried this and this tutorials and in both (and everywhere) @SpringBootApplication seems to be sufficient to make the repository reachable throughout…

Scaramouche
- 3,188
- 2
- 20
- 46
1
vote
2 answers
Exclude some components of a Microservice
I am a new bee and using microservices(Spring Boot, Spring Cloud) in which I am trying to use resource file of a microservice in another. For that I need to scan that module in another one via ComponentScan.
Like I have an Admin module in which I…

maddy
- 248
- 1
- 5
- 16
1
vote
0 answers
Best way to specify autowire candidate for profile
In my spring boot application for some interfaces I have several implementations (usually "main implementation" and "implementation for local testing") which I use with different profiles. I know several options to tell spring to use specific…

Sergey Galkin
- 159
- 3
- 8
1
vote
1 answer
Exclude class from ComponentScan of SpringBoot
I have two classes out of which I want to use only one class at run-time (depending on if I am running tests or executing the app on a server(local or otherwise)) and exclude the other from Spring's Component Scanning.
Here the 1st class which I…

Akshay Singh
- 93
- 10
1
vote
1 answer
want to filter scanned jars for Spring component scanning
I am trying to optimize a massive Spring 4, Tomcat app. Startup time is about 2 mins, and I'm wondering if there is a way to exclude certain jar files from being scanned? e.g., I don't need commons-lang being scanned b/c Spring doeesn't care about…

Ron Stevenson
- 166
- 1
- 13
1
vote
0 answers
Interceptor is not get invoked if get beans created in servlet-context in spring-config. in Spring Framework
I added code in servlet context instead of spring-web.xml, that time interceptor not got invoked, but when I added in spring-web.xml it invoked.. Not getting reason. Is any one can tell the reason.
Web.xml
…

Vivek Nerle
- 304
- 2
- 14
1
vote
1 answer
How to scan both current and some other package with @ComponentScan?
If I write only
@ComponentScan
Spring will scan the current package and below.
If I write
@ComponentScan(basePackages = {"my.package.com"})
Can I specify current package implicitly along with some explicit packages?
Something like…

Suzan Cioc
- 29,281
- 63
- 213
- 385
1
vote
0 answers
Field properties in ... required a bean of type ... that could not be found
I have the following project structure:
ApplicationConfiguration:
@Configuration
@ComponentScan(basePackages = {"configuration", "nsd"}) //<- base packages here
public class ApplicationConfiguration…

gstackoverflow
- 36,709
- 117
- 359
- 710
1
vote
1 answer
How spring scan all the classes under specified package with ?
I was thinking using reflection, spring scanning all the classes and it's annotations, method. But I heard using reflection can't get class details with package name.
Then how spring scan classes under specified package?

Arunkumar
- 107
- 1
- 3
1
vote
0 answers
loading beans from XML (programmatic way) does not work
After loading beans using XmlBeanDefinitionReader's loadBeanDefinitions method , Auto scan feature of spring xml does not work as all the beans mentioned in the xml gets created but the beans which are marked by @Component to auto detect are not…

Prashant Pandey
- 41
- 6
1
vote
2 answers
How to avoid to configure an external library by another library using Spring Boot
Let’s assume I have two Spring boot projects. The first project is just a supporting library providing various functionalities. The second is the “main” project (primary library) which uses the supporting project (jar).
The supporting library has…

Horowitzathome
- 359
- 3
- 13