Questions regarding using `@ComponentScan` to detect Spring managed components
Questions tagged [component-scan]
129 questions
0
votes
0 answers
Can't retrieve the spring application context in a multimodule springboot project / EntityManagerFactory can not be found
I have a multimodule springboot project. Here is the architecture:
The class annotated with @SpringBootApplication is in the top module (webservice). When I run integration test from this top module using @SpringBootTestin my test classes, it works…

Julien Berthoud
- 721
- 8
- 24
0
votes
2 answers
NoSuchBeanDefinitionException with Quartz in test
I have a Spring Boot (2.1.3) project using the Quartz scheduler. It is included via the starter:
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter-quartz')
}
The application is (mainly) configured with…

deamon
- 89,107
- 111
- 320
- 448
0
votes
1 answer
Why isn't my config class annotated with @Configurable and @ComponentScan not initializing beans twice?
I have read that
"The fact that @Configuration classes are @Components also means that your @Configuration classes are picked up automatically if you have component scanning enabled on the package that contains them. This can have both intended and…

katiex7
- 863
- 12
- 23
0
votes
0 answers
Spring component scan does not work for a packages with similar names within a jar
I am running a component scan on a jar where I load a few packages. The package
com.path.package works fine and is getting loaded but then beans within com.path.package.addon is not getting loaded in by the component scan

vignesh
- 37
- 1
- 8
0
votes
4 answers
Spring - @ComponentScan not detecting the beans
I'm new to Spring. I'm trying to use ComponentScan.I have a simple bean with a string variable annotated with @Component. Trying to use the @Configuration with a java class instead of xml file. When I try to access the bean from my main class, it…

Madhu Kumar Tallapalli
- 75
- 2
- 10
0
votes
0 answers
Is there is a way to know what configuration class creates bean?
I wonder if there is a way in Spring to know what configuration triggers creation of a particular bean? So the case is the following: there are some @Configuration marked classes, some of them may be also annotated with @ComponentScan annotation.…

Dmitry Senkovich
- 5,521
- 8
- 37
- 74
0
votes
0 answers
Spring scan all controller when it is not declared in component scan
I am working on a project in Spring, which consists of some small project and dependencies. Here's the simple hierarchy of the parent project:
A (a war, the rest web services that will be exposed)
B (another war, which will also be exposed)
C (jar…

Silly Sally
- 1,027
- 2
- 10
- 15
0
votes
2 answers
Exclude @SpringBootApplication from component scanning
I have two classes marked as @SpringBootApplication under one directory:
@SpringBootApplication
public class FirstSpringBootApplication
and
@SpringBootApplication
public class SecondSpringBootApplication
@SpringBootApplication annotation…

Serhii Soboliev
- 820
- 1
- 13
- 21
0
votes
1 answer
component-scan not finding @Repository
My classes look like this:
AbstractDAO
package dao.impl;
public abstract class AbstractDAO implements DAO {
@PersistenceContext
private EntityManager em;
public void add(E entity) {
em.persist(entity);
}
}
DAOImpl
package…

Daniel Marín
- 113
- 1
- 11
0
votes
2 answers
How can I specify into the Spring XML configuration to perform the component-scan on two different packages?
I am pretty new in Spring MVC and I have the following problem.
In the application on which I am working I have 2 controllers classes declared into two different packages.
So I am trying to specify into my XML configuration the second package that…

AndreaNobili
- 40,955
- 107
- 324
- 596
0
votes
1 answer
Spring web app start up - @ComponentScan - app context and web context
Our Spring MVC web app is trying to follow the recommended style. It uses AppContext (ContextLoaderListener) to store the DAO's and Services. It uses WebAppContext (DispatcherServlet) to store Controllers.
The DAO objects are getting into both the…

John
- 1,635
- 15
- 22
0
votes
0 answers
SpringBootApplication annotation start time overhead
I want to create a new Spring Boot web application.
My structure should be the following:
com.base.package
MyApplication
config
domain
repository
service
…

Nailgun
- 3,999
- 4
- 31
- 46
0
votes
1 answer
component-scan get in the way of bean initialization?
I encounter this problem while I am trying to duplicate a simple spring OAuth project, sparklr2. source code here
https://github.com/spring-projects/spring-security-oauth/tree/master/samples/oauth2/sparklr
the source code runs perfectly, when I…

Maxi Wu
- 1,274
- 3
- 20
- 38
0
votes
1 answer
context:component-scan cannot be defined
I am having a problem with the Spring-contex definitions. When I look at other people who had this problem, it was normally becasue of usign the wrong schema declerations, but I don't think this is the case with my issue.
Line 21 in XML document…

kobi
- 119
- 1
- 2
- 12
0
votes
0 answers
how spring component scan feature can assure your web site security is not compromised?
say i have a working spring mvc web app which includes the following,
apparently this project depends on a few 3rd open source libraries including spring framework,…

zhoubig
- 23
- 1
- 4