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
6
votes
1 answer

Does spring initialize beans in parallel?

I have a lot of independent spring beans in my project (classes annotated with @Component -- NOT lazily initialized). I wanted to know weather the beans will be initialized serially or parallely? I am asking this because the beans modify a common…
ishan3243
  • 1,870
  • 4
  • 30
  • 49
6
votes
0 answers

How to persist spring sessions into custom back-end data store

I have a spring MVC web application, I have java classes that I have annotated with @Scope("session") and currently running it on tomcat. The classes annotated with the scope store user information that I don't want to lose in case the server…
tigg
  • 107
  • 8
6
votes
2 answers

How to create a Spring session scoped bean based on user properties

I've developed a Spring Web-MVC application. I have some offices in my project. Each user belongs to an office. user.getOfficeType() returns an integer representing the user's office type. If the office type is 1, the user belongs to Office1 and…
Dariush Jafari
  • 5,223
  • 7
  • 42
  • 71
6
votes
1 answer

Can't understand `@Autowired HttpServletRequest` of spring-mvc well

In our spring application, we use HttpServletRequest in two ways: (the code here are simplied, and seems meaningless) In the controller: @RequestMapping(value = "/hello", method = RequestMethod.GET) @ResponseBody public ResponseEntity
Freewind
  • 193,756
  • 157
  • 432
  • 708
6
votes
2 answers

No bean class specified on bean definition

I am sorry that this is probably too vague and generel of a question. I am trying to bring up a huge legacy project with tons of spring wirings, and I am getting this error: The bizzare thing is this error does not tell me on which xml, which bean…
CuriousMind
  • 15,168
  • 20
  • 82
  • 120
6
votes
1 answer

How to get externally defined bean in java config

I have a java config class that imports xml files with the @ImportResources annotation. In the java config I'd like to reference to beans that are defined in the xml config, e.g. like: @Configuration @ImportResource({ …
James
  • 11,654
  • 6
  • 52
  • 81
5
votes
0 answers

Expose Spring Beans to a Micronaut Application

Is it possible to Expose Spring Beans to a Micronaut Application and use them with @Autowired or @Inject them into the Micronaut Application with the Spring Beans project added as Maven Dependency to the Micronaut Project via Maven pom.xml? The…
shravind
  • 51
  • 2
5
votes
1 answer

Should we use "final" keyword for @Auotowired inject Bean

I usually see in other codes which use final key word to inject Service Bean to Controllers, some code are not. So, what's the reason to use "final" in this. I know final variable that means it's immutable variable. I research some blogs that they…
5
votes
2 answers

Spring Unit Testing: Using @SpyBean to mock a void method: getting NullPointerException for that bean unless I use @Mock instead

i am trying to make @SpyBean or @MockBean work in this test as they are working in all my other tests. the only difference here is this test uses an active profile because it mocks some AWS libs I shouldnt have to instantiate the class it if I am…
heug
  • 982
  • 2
  • 11
  • 23
5
votes
1 answer

@PostConstruct not called when using Kotlin BeanDefinitionDsl

It seems that the @PostConstruct method is not called when a bean is added to the context using a Kotlin BeanDefinitionDsl. This happened to me in my own project but to create a simple way to reproduce it, here's what I did. I forked the Spring…
BPS
  • 1,606
  • 20
  • 37
5
votes
0 answers

Ignore properties for nested fields of spring BeanUtils is not working

How to define ignore properties for nested properties to spring BeanUtils? BeanUtils.copyProperties(source, target, ignorePropertiesName); I have class Contact with nested class Name and their two propeties 'firstName' and 'lastname'. I tried…
Ash
  • 2,095
  • 1
  • 19
  • 17
5
votes
2 answers

How to autowire spring-data CrudRepository

A bit of Details I am having some problem while running the code given below. I am getting the following exception. When i am trying the sample code of [CrudRepository for Spring Data][1]. I have an Interface: package com.joydeep.springboot;…
Joydeep
  • 401
  • 2
  • 6
  • 15
5
votes
1 answer

Async Bean initialization

Initialization of a specific bean requires performing a network connection. This may take some time, and unnecessarily blocks the already long startup by a few seconds. Is there any way for my bean to signal that it isn't yet initialized even after…
f.khantsis
  • 3,256
  • 5
  • 50
  • 67
5
votes
2 answers

Spring boot 1.4.2.RELEASE error on startup java.lang.ClassNotFoundException: org.springframework.beans.factory.ObjectProvider

I am trying to upgrade spring-boot from 1.3 to 1.4.2.RELEASE. Running mvn spring-boot:run throws the following error. java.lang.IllegalStateException: Error processing condition on…
Juzer Ali
  • 4,109
  • 3
  • 35
  • 62
5
votes
0 answers

Spring throws 'IllegalStateException: ApplicationEventMulticaster not initialized' when unused bean removed

I recently removed an unused Injected bean in a DAO class and it caused the following stack trace error in Tomcat on startup though the application functions as expected. When I replace this unused Auto-wired bean definition it seems to go away…
Adam James
  • 3,833
  • 6
  • 28
  • 47