spring - @Resource becomes null when Java Config implements AsyncConfigurer -


I have a very strange problem. I'm using Spring 3.2.4 and there is a Spring Java Config Class which is Java and XML configuration is part of a large mix of files.

Uses 6 resources defined in other config files to use the file @ async bean when I add "async config implementer" in the file, then some @resource fields in the form of zero , But when I stop implementing, they are populated. This is confusing because asynchronous configurator should only be used to configure your asynchronous executor, nothing should look like your configuration load asynchronous.

When I set the debugger on the construction method, I can see that beans are really null. This appears to be the race situation of any kind, because of the 6 beans, the fourth was once a goat, and then the next time it was populated.

My file appears:

  Public class userbackhoundprocessor configuration async configurrer {@resources (name = "bean 1") MyBan Bean 1; // In reality, 6 @ resources have been defined ... @resources (name = "bean 6") MyBean bean6; @bean (name = "background_progress") public pageproseposcope getBackgroundProcessor () {pageviewProcessor background_act = new pageprocessor (); BackgroundProcess.setBean1 (bean1); // Beans 1-3 are always populated / bean 4 seems to sometimes populate, sometimes null & beans 5 and 6 are always the null background process. SATBAN 6 (bean 6); Return page process; } @overराइड @ बीन (name = "executable") public executable getAsyncExecutor () {ThreadPoolTaskExecutor Executor = New ThreadPoolTaskExecutor (); Executor.setCorePoolSize (10); Executor.setMaxPoolSize (40); Executor.setQueueCapacity (25); Executor.setThreadNamePrefix ("BackgroundProcessor-"); Return executor; Again, when I remove "I am using ASCII Configurator" and comment on getAsyncExecutor, then the problem is resolved.  

p> Interface can be implemented by @EnableAsync, annotated @ configuration class, which is the ASC method Invoices want to customize the executable example used while processing.

So I do not know that I am seeing behavior.

It appears that your background processor appears on your 6 resource beans.

Try signing a comment with this method:

  @Bean (name = "backgroundprocessor") @DependsOn ("bean1", "bean2", "bean3" , "Bean 4", "Bean 5", "Bean 6") public pageprospector getBackgroundProcessor () {.}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -