Questions tagged [spring-bean]

A simple JavaBean managed by the Spring IoC container.

A simple JavaBean managed by the Spring IoC container. These beans are created with the configuration metadata that is supplied to the container, for example, in the form of XML <bean/> definitions or @Bean annotation. Actually, the BeanFactory is the main IoC container which instantiates, configures, and manages these beans. These beans typically have associations with each other, and therefore have dependencies between themselves. These dependencies are configured in the configuration files used by the BeanFactory. Other dependencies that are invisible from the configuration file could be a function of programmatic interactions between beans at run-time.

767 questions
3
votes
0 answers

Ignored Beans in SpringBootTest Configuration

I have the following structure; Main Config Class; @TestConfiguration @Import({MainApplication.class, ConfigA.class, ConfigB.class}) public class MainTestConfiguration { } And two separate config classes; @TestConfiguration public class ConfigA { …
3
votes
1 answer

Spring 4.2+ : How to reference a Spring bean instance from inside an @EventListener condition expression

In Spring 4.2+, we can use @EventListener annotation with a "condition" expression. In my scenario, I need to match the id of the event object with a regular expression that is configured in a .properties file. However, it seems impossible to…
Maikel Nait
  • 251
  • 3
  • 18
3
votes
1 answer

Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList'

I need to add spring security with my custom authentication provider class. This is my security configuration file.
user1289
  • 1,251
  • 2
  • 13
  • 25
3
votes
2 answers

Why would Spring 3 @Component names clash when they have different packages?

I've got two classes: package package1; @Component public class MyClass1 { ... package package2; @Component public class MyClass1 { ... When I run failsafe (in maven) - I get the following error in spring (that I don't get in…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
3
votes
2 answers

dynamically replace the value to placeholder in config xml file in Spring Batch

I am using Spring Batch 2 version. I am reading data from database using JdbcCursorItemReader.I have successfully fetched the data and also written it to a file. Below is itemReader bean defined in Job.xml File::
Mugdha
  • 31
  • 2
3
votes
1 answer

Spring - Don't create bean if a primary bean is present

Is it possible to prevent the creation of a bean of type A if it could be generated as a primary bean Example: I have two configuration classes and have two profiles. AppConfig.java: (The generic configuration class having all…
Thiyagu
  • 17,362
  • 5
  • 42
  • 79
3
votes
2 answers

No qualifying bean of type "myOwnType" - Primitive beans like String works

I have a Spring project and try to pass the services application context to an other service which is "spring free". My Spring project: @Service public class MySpringService implements MyApi { ... private static MySpringService…
grimbo
  • 95
  • 1
  • 11
3
votes
1 answer

Getting a Single object of model Class in Spring framework

Hi guys I developing a spring application and got stuck in one place. What I am doing is fetching the data from the database using spring rowmapper. The problem is while implementing the rowmapper class Model class object is creating exactly the…
Vivek Singh
  • 646
  • 3
  • 10
  • 25
3
votes
1 answer

NullPointerException in transactionAdviser (Spring boot application)

I am stuck with a strange exception while developing a Spring Boot Application. I browsed a lot but couldn't find much to the rescue. Here is what I have: org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
3
votes
1 answer

Spring prototype beans with parameters?

Is it possible to define a prototype bean, using XML config or annotation-based config such that I can get an instance of the bean with a custom parameter value? My use case is a message queue handler that makes API calls with different parameter…
Marty Chang
  • 6,269
  • 5
  • 16
  • 25
3
votes
2 answers

Is Map> possible to declare in Spring

I have a class with the following constructor: public MyClass(Map> co){ //impl } I need to invoke it via Spring bean's declarations. I tried to do something like this:
St.Antario
  • 26,175
  • 41
  • 130
  • 318
3
votes
2 answers

What is the equivalent of factory-method="aspectOf" for a @Bean?

What is the equivalent of when using a Spring 4 @Bean-annotated method?
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
3
votes
1 answer

accessing a request-scoped bean in HandlerIntercaptor

I'm very new to Spring and web development in general, so please bear with me if the question seems confused or incomplete... I'm currently working on a Spring project in which there is a bean I'll call 'requestContext' which holds some commonly…
ryoaska
  • 307
  • 5
  • 17
3
votes
2 answers

Grails - Best Way to Access Beans in Normal Groovy Classes

I'm trying to inject an existing bean into a Groovy class and I know Grails bean injection doesn't work for normal Groovy classes (in src/groovy folder). I can get access to a bean via Holders.applicationContext.getBean('beanName') However, I'm…
Harry Muscle
  • 2,247
  • 4
  • 38
  • 62
3
votes
1 answer

Initialize spring bean profile through ContextLoaderListener in web.xml

In my web.xml I'm declaring a ContextLoaderListener to configure spring application this way: org.springframework.web.context.ContextLoaderListener In one of my spring configuration…
bachr
  • 5,780
  • 12
  • 57
  • 92