Questions tagged [component-scan]

Questions regarding using `@ComponentScan` to detect Spring managed components

129 questions
2
votes
2 answers

@Autowired not working with resteasy

I know this has been asked before, but I've checked this code against all the answers provided and still cannot see what is wrong with it... My @Autowired fields are simply not being injected (ie. they are null), here is my setup: Tomcat 7 RestEasy…
dhalia
  • 401
  • 5
  • 21
2
votes
2 answers

Spring, component-scan causes FatalBeanException around NamespaceHandler

When I use component-scan I get the folowing exception: Caused By: org.springframework.beans.FatalBeanException: Class [org.springframework.context.config.ContextNamespaceHandler] for namespace [http://www.springframework.org/schema/context] does…
Thomas Beauvais
  • 1,546
  • 2
  • 16
  • 30
1
vote
0 answers

Why does SpringBootTest ComponentScan finds a bean outside of the basePackages and tries to create it?

I have a @SpringBootTest that use a @Configuration class with @ComponentScan: @SpringBootTest(classes = BaseTest.Conf.class) public class SocGenTest extends BaseTest { And the configuration class: public class BaseTest { @Configuration …
selalerer
  • 3,766
  • 2
  • 23
  • 33
1
vote
2 answers

Component Scan using application.properties in spring boot app

I made a java library that has component and configuration classes. When I use the library in other spring boot services, the beans are not registered because the component and configuration classes are not in the classpath. I know we can use…
1
vote
0 answers

Excluding @bean from ComponentScan

I have lot of beans declared in a single class package com.example; @Configuration public class MainBeanClass{ @Override @Bean("cachingSession") @Lazy public CqlSessionFactoryBean cassandraSession() { /**/ } @Bean public String…
Vijay Manohar
  • 473
  • 1
  • 7
  • 22
1
vote
1 answer

My component scan on Spring 5.3.18 does not work

I have little problem with spring ComponentScan in my application. Here is my Test spring configuration: @Configuration @ComponentScan(basePackages = {"com.dhl.cdm","com.dhl.common.dao"}) @EnableTransactionManagement public class TestConfiguration…
Petr Kostroun
  • 456
  • 9
  • 27
1
vote
1 answer

In a Spring Boot application how can I scan for a method return type and the annoatation value using the return type annoatation as a filter?

trying to scan for return type objects that are annoated with a custom annoation but the ClassPathScanningCandidateComponentProvider does not find them even though package is correct and metadata shows the methods annoated with them. I've added a…
Parawata
  • 41
  • 3
1
vote
1 answer

Spring configuring bean with component scan - Field userRepository in service.UserService required a bean of type 'repository

I have checked many examples but they are generally about marking the classes with @Repository or @Service etc...For example here it is about the packages to scan and I am not sure where and in which method I should make scan. I have a simple…
1
vote
1 answer

Does Spring implement its own packages scan

Does Spring implements its own way to scan the class in packages or does it use a external library like 'reflection': https://github.com/ronmamo/reflections
1
vote
3 answers

Should @ComponentScan stay in the class containing the main method?

I know that @ComponentScan with @Configuration tell Spring where to look for beans. @ComponentScan @Configuration public class MyApp{ ... } What I do not understand is on which class I have to put these two annotations. Should they stay on the…
Stefano Sambruna
  • 767
  • 2
  • 10
  • 29
1
vote
1 answer

Spring boot 404 not found Error message": "No message available

Hello I'm working with a Spring boot App connecting to a mongo db, my problem is that my endpoint are not working it seems that they are not found by Component scan. I'm have been crazy because I'm blocked to continue developing and I'm not able to…
rasilvap
  • 1,771
  • 3
  • 31
  • 70
1
vote
0 answers

Spring Boot Controllers not working 404 error

I'm developing a Spring boot application and my endpoints are not working at all. I'm getting the next issue: { "timestamp": "2020-06-21T21:12:39.716+0000", "status": 404, "error": "Not Found", "message": "No message available", …
rasilvap
  • 1,771
  • 3
  • 31
  • 70
1
vote
1 answer

ComponentScan does not find own custom annotations after update from Spring Boot 2.0.3 to 2.2.4

Prior to the update from Spring Boot 2.0.3 to 2.2.4 we had some annotations like the following example: import org.springframework.stereotype.Component; @Component public @interface Adapter { } During ComponentScan classes annotated with this…
1
vote
1 answer

Spring cannot include/exclude beans using filters of type REGEX with an asterisk in @ComponentScan

I am trying to manage the beans my spring application loads using IncludeFilters property of @ComponentScan annotation. I use filter of type FilterType.REGEX. I would like to match anything as the last part of my pattern using but I seems not to…
CaptainAye
  • 409
  • 2
  • 9
1
vote
2 answers

After adding @ComponentScan to load beans from a jar my controllers isn't scan and i get 404

I have a spring-boot application (Java8, spring-boot 2.1.4-RELEASE). One of the services in the business layer need to @Autowire a bean from a certain jars in my classpath. In order to achieve that i had to add…
Liav Ezer
  • 29
  • 5
1 2 3
8 9