Questions regarding using `@ComponentScan` to detect Spring managed components
Questions tagged [component-scan]
129 questions
0
votes
1 answer
Spring boot @ComponentScan. How to exclude all packages from scan except one subpackage or class?
@ComponentScan(
excludeFilters = {
@ComponentScan.Filter(
type = FilterType.REGEX,
pattern =
"com.base.package.*"
)
)
Under com.base.package. there is a class that I do not want to be excluded, how can I…

Developer1234567
- 33
- 2
- 7
0
votes
1 answer
IntegrationComponentScan with an explicit basePackages required in Spring Boot?
I have a Spring Boot application (using Spring Boot 2.4.11) where I'm using Spring Integration. I added the org.springframework.boot:spring-boot-starter-integration and hence I expected @IntegrationComponentScan to be active by default. Indeed, I…

Mauro Molinari
- 1,246
- 2
- 14
- 24
0
votes
0 answers
Missing bean in controller even after adding ComponentScan annotation
I am trying to run a spring boot application which gets a list of names of people from the database. I am getting the below error :
Description:
Field peopleserviceinterface in com.sample.lombpackdemo.controller.FriendController required a bean of…

Pisces1719
- 25
- 6
0
votes
1 answer
Whitelabel Error Page the controller cannot be scanned - Spring boot- jsp
I am learning how to build web application by spring boot.
When I try to use controller to use @Controller to show the jsp page, the "Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback."…

Isao
- 11
- 1
- 3
0
votes
1 answer
spring submodule bean not loading
I am having DemoService class in test-client module. Injecting this DemoService class from test-server module.
1st case(working):
Both test-server and test-client has root package as com.demo.test .
This case all the beans are loading.
2nd case:…

Remo
- 534
- 7
- 26
0
votes
1 answer
How to properly configure multiple component scans and "use default filters = false"
I'm developing a "new application" that wants to leverage code in an existing application, but I am having trouble getting "contextLoads()" to pass in the new application.
This configuration doesn't work:
//This is the main common library B…

geneSummons
- 907
- 5
- 15
0
votes
0 answers
Figure out where spring application is scanning for components
Ok, so I want to use a ClassPathScanningCandidateComponentProvider to find components that have a method that is annotated with a custom annotation.
I've done similar before. However, this time, I'm in a library that's being used by an application…

User1291
- 7,664
- 8
- 51
- 108
0
votes
1 answer
How to understand the annotation @ComponentScan work when wiring Bean without application.xml?
1, When my dictionary tree likes these, the error "@EnableAsync annotation metadata was not injected" occurs。
2, But when my dictionary tree likes this, the error doesn't happen.
3, When I wire Bean with application.xml, and the dictionary tree…

Helin
- 65
- 1
- 4
0
votes
1 answer
Spring doesnt see one specific module
In multi module maven project Spring scans everything but one module:
So, @Component/ @Controller annotations in ui module are being ignored by Spring
Any other bean is under the reach of the context:
Spring Config:
I do believe there is no typo…

tarmogoyf
- 298
- 3
- 17
0
votes
0 answers
Component scan a class for HandlerExceptionResolver
I have a class for HandlerExceptionResolver
@Service
public class GlobalHandlerExceptionResolver implements HandlerExceptionResolver{
@Override
public ModelAndView resolveException(HttpServletRequest req, HttpServletResponse resp,Object…

GreyWolf18
- 141
- 1
- 3
- 13
0
votes
0 answers
Spring component scan doesn't load its own components if I change basePackages?
I'm trying to get started with Spring Boot so I can use it in my future projects.
However after I implemented my "authentication" library which contains some simple user service (implementation of UserDetailsService), I tried to integrate that into…

Doru Chiulan
- 307
- 4
- 15
0
votes
1 answer
ComponentScan ignores excludeFilters (in test)
I can't figure out, how to exclude a configuration (e.g. as described here) in a test. What I really want is to ignore a configuration in a @WebMvcTest, but even the following simpler example does not work for…

Darkwyng
- 130
- 1
- 7
0
votes
2 answers
Spring Boot Component Scan Context
I have 10+ Spring Boot applications that can be built as war files and deployed within and application server, or run individually as standalone. Each application contains unique code, functionality, and RESTful services required for business…

cain4355
- 1,094
- 1
- 10
- 22
0
votes
0 answers
Using @ComponentScan in SpringBoot leads to error
I've build a sample Spring Boot Application and wan't to enable asset-pipeline. When following the tutorial it's necessary to enable @ComponentScan. But after enabling it, the application won't start and throws the following…

PascalTurbo
- 2,189
- 3
- 24
- 41
0
votes
1 answer
find package name - Spring Boot library
I'm making a library to be used with Spring Boot. This lib define some annotations that can be used in methods.
How can I find (at runtime) the package of the application where the library is being used?
I need this in order to scan for the…

Lucas Noetzold
- 1,670
- 1
- 13
- 29