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

Configuration in what context

I have a root context that have all business bean (it is the root context)
esoni
  • 1,362
  • 4
  • 24
  • 37
2
votes
1 answer

Why spring beans are not created in jar files, but in class files

I am using spring for some dependency injection via the annotations. The problem ist whenever I start the application and use the .jar ,created by gradle, in the classpath Im getting the following exception:…
hadamard
  • 401
  • 4
  • 16
2
votes
1 answer

Making a bean primary without annotation or xml config

My project has a dependency on another one, and imports beans from it (using @ImportResource("foo.xml")). foo.xml defines two datasources (datasource1 and datasource2), I would like to make datasource1 a primary (so all auto-configurations of Spring…
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
2
votes
3 answers

How to create Spring Beans in a dynamical way. Using Quartz SchedulerFactoryBean

I have a QuartzJobConfig class where I register my Spring-Quartz-Beans. I followed the instruction of the SchedulerFactoryBean, JobDetailFactoryBean and CronTriggerFactoryBean. My Jobs are configured in a yaml file outside the application. Means I…
Patrick
  • 12,336
  • 15
  • 73
  • 115
2
votes
1 answer

IllegalStateException when creating EntityManagerFactory Bean

I am getting the following exception when attempting to load my EntityManagerFactory Bean. SEVERE: Exception sending context initialized event to listener instance of class…
user856354
  • 273
  • 3
  • 6
  • 21
2
votes
1 answer

Spring boot service start up error java.lang.NoSuchFieldError: INSTANCE

Once the spring boot application is upgraded to spring-data-cassandra:1.5.0.M1 seeing the below error. the service is not starting. Stack Trace: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name…
2
votes
1 answer

Spring PostConstruct of a container

How can I run some code inside a Spring Container after all beans has been loaded? I know I can use @PostConstruct for a single bean, but I would like to run that piece of code after all PostConstructs are called. Is is possibile? ---UPDATE--- I…
Tobia
  • 9,165
  • 28
  • 114
  • 219
2
votes
1 answer

Spring declare multiple beans

I have an HashMap of myobjects which I want to loop through and declare each one of them as bean. At the end I want to choose one particular key as @primary. Is there anyway to do this in Spring Java Config? I can't really do this in listeners as…
Abhijith Prabhakar
  • 1,325
  • 3
  • 12
  • 24
2
votes
1 answer

Can I create a bean from a SpEL expression directly?

I have a SpEL expression that generates a SpEL list. (The result type is actually a Java array, but no sense quibbling.) I want "promote" the result of my SpEL expression to a bean in my Spring XML beans configuration file. One way to do this that…
0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
2
votes
0 answers

spring replaced bean by instance of cglib generated class

At the some moment(I mean it can works fine for a few days-weeks) in my app spring replaced my autowired bean(which was wrapped by proxy) to instance of class which has been generated by cglib(after replace the issue reproduce every time). It…
Behemoth
  • 125
  • 1
  • 10
2
votes
1 answer

How to initialize beans in proper order if some beans are present in test mode only?

Good day. My Spring Boot app uses Postgress database. For tests it uses H2 database. When running in non-test mode beans need to be initialized in this order: 1) Init DataSource 2) Init JPA beans When running in test mode I need to create and…
Vojtech
  • 2,533
  • 9
  • 34
  • 65
2
votes
1 answer

Receiving a Spring RequestMappingHandlerMapping error in Google App Engine

I have built a simple Spring MVC application that works flawlessly on my local machine. Having uploaded it to the Google App Engine, however, I receive a HTTP 500 error. Looking into the logs I recieve this INFO…
andrewvincent7
  • 151
  • 2
  • 7
2
votes
1 answer

Autowired websockets SimpMessagingTemplate produced null on all resources

Whole magic here what it crashes only on linux\server\laptop machine and perfectly working(autowiring) on mac. I have @EnableWebSocketMessageBroker @Configuration public class WebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer…
2
votes
0 answers

URLConnection execute in Spring bean return code 403

I develop a Java class which contain a method open a URL connection to RESTFUL and get data. If I run it as Java application (main function), it run good, server return code 200 OK with data returned. But when I try to call that method in another…
2
votes
3 answers

Spring-using library defined beans conflict with application

I have several spring-boot web applications and a single integration library used by all the web applications. The integration library makes use of Spring for DI and defines several of its own @Beans with explicit names assigned, notably an…
James Dunne
  • 3,607
  • 3
  • 24
  • 29