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
2
votes
0 answers

Java Spring Servlet cannot find Bean in another ApplicationContext

I am new to Java Spring, so I may have some difficulties explaining my configurations. I have a Java Spring Web Application that contains a Servlet that needs to access a Bean. However, the issue is the Bean is located in another common project xml…
Chen
  • 103
  • 1
  • 9
2
votes
1 answer

Spring 3.2: Cannot autowire @Service annotated bean into a @Bean annotated bean - BeanNotFoundException occurring

I didn't want to have to ask a question on here, but I've had a look at over 20 other similar issues on Stack Overflow, and none of them seem to be the exact same scenario! I have a @Service annotated bean (Service1.java) which I am trying to…
Jon Betts
  • 234
  • 3
  • 16
2
votes
2 answers

Validate all strings fields in RequestBody and Param

I'm using spring-boot based rest services and looking to apply a default validation on all strings. I want to apply a default validation on any string field that is part of a @RequestBody or @Param. Note: I need a default validation, i.e. I want to…
ab m
  • 422
  • 3
  • 17
2
votes
0 answers

Spring Boot beans not added to context using Bazel

I have one Spring Boot application that uses Bazel to manage all of its dependencies, that I migrated from Maven. I'm able to launch the app using Bazel, but after checking all of its beans I noticed that are missing the beans of the classes that I…
Nunovsky
  • 365
  • 4
  • 18
2
votes
0 answers

Will Spring creates a bean using @DependsOn after @PostConstruct of other bean?

We have 4 Beans BeanA, BeanB, BeanC, BeanD We have a cache in BeanA which gets filled in the @PostConstruct of BeanA. Now, BeanB also have a cache which gets filled in the @PostConstruct of BeanB. BeanB's cache depends on the BeanA's cache. So BeanB…
Avinash Kharche
  • 411
  • 9
  • 25
2
votes
0 answers

How do I access a previously created bean in Prototype bean?

I want to create a bean with a unique name that I have given at any time. I also want to create a new instance with this unique name every time I call it. I just want to reach the old instance of a bean with that unique name is created in some…
omerstack
  • 535
  • 9
  • 23
2
votes
1 answer

Spring - creating bean from collection or map

Some time ago i read about creating beans in Spring and there is an exception in creating bean for collections and maps. I mean to create a bean for collection or map, it is needed to create a wrapper class with for example a list as a field of this…
Centos
  • 250
  • 3
  • 13
2
votes
1 answer

Kotlin inner class as Spring Bean

I used Kotlin with Spring boot and i met some errors about bean creation. error message was Index 0 out of bounds for length 0 in spring framework class i dont understand why caused exception about this java code(spring) for (int paramIndex = 0;…
unilep
  • 313
  • 2
  • 9
2
votes
0 answers

REST api testing and accessing a repository bean or a service bean

I need to test rest api and need to access repository beans and service beans that are behind controllers in my Spring we application. How do I access them? Using JMX is it possible? AccountRepository accountRepository = getBean(austin,…
Julie
  • 179
  • 2
  • 13
2
votes
0 answers

IntelliJ Spring Bean Dependency Diagram for project files only

When you create a Spring Bean Dependency Diagram in IntelliJ, this massive dependency graph is created with most of the beans from the Spring framework itself. In fact, most of them are even stand-alone nodes in the graph with no connections…
Snackoverflow
  • 5,332
  • 7
  • 39
  • 69
2
votes
2 answers

Connecting database entries to spring beans

The title may be a bit misleading but I am trying to find the best solution in connecting database entries to spring beans. I hope that the example that follows will clarify things. For starters, I have a Task entity. @Entity @Table( name =…
Dimitar Spasovski
  • 2,023
  • 9
  • 29
  • 45
2
votes
2 answers

Reinitialize spring @Autowire bean

I have a scenario where I need to initialize a bean based on application configuration during startup. Later, due to dynamic configuration fetched based on an event, I have to update the bean. This bean can't be updated but can only be replaced with…
Sunil Dabburi
  • 1,442
  • 12
  • 18
2
votes
5 answers

Why is spring boot not finding my beans?

i have following error: Parameter 0 of constructor in com.yyy.zzz.xxx.service.ControlService required a bean of type 'com.yyy.zzz.xxx.service.composeXML.ComposeCounterService' that could not be found. Usually this is because i forget to annotate…
Clomez
  • 1,410
  • 3
  • 21
  • 41
2
votes
3 answers

Spring conditional component scan configuration

I have a configuration class which registers beans based on a very simple condition (checking a property value in application.properties). The configuration class and the condition are the following:…
2
votes
2 answers

Self injecting prototype bean - cyclic reference

I need to self-inject prototype bean. As I know, it is possible if bean scope="singleton", but in this case I get message from spring : "The dependencies of some of the beans in the application context form a cycle: postMan2" My…
Leo
  • 1,029
  • 4
  • 19
  • 40