2012-06-04 50 views
4

我正在使用一個自定義的MVC應用程序,它具有SPring批處理的相關性,如其文檔中所述,並由此SO疑難問題Integrating Spring Batch Admin into an existing application協助。Spring批處理 - 沒有定義名爲'job-configurations'的bean

現在的麻煩是,當網絡應用程序開始將各種URL映射到適當的控制器時,作業配置步驟就會彈出。

2012-06-04 10:17:54,966 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - <Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'> 
2012-06-04 10:17:55,512 INFO [org.springframework.ui.freemarker.SpringTemplateLoader] - <SpringTemplateLoader for FreeMarker: using resource loader [WebApplicationContext for namespace 'admin-servlet': startup date [Mon Jun 04 10:17:54 EDT 2012]; parent: Root WebApplicationContext] and template loader path [/WEB-INF/web/]> 
2012-06-04 10:17:55,512 INFO [org.springframework.ui.freemarker.SpringTemplateLoader] - <SpringTemplateLoader for FreeMarker: using resource loader [WebApplicationContext for namespace 'admin-servlet': startup date [Mon Jun 04 10:17:54 EDT 2012]; parent: Root WebApplicationContext] and template loader path [classpath:/org/springframework/batch/admin/web/]> 
2012-06-04 10:17:55,512 INFO [org.springframework.batch.admin.web.freemarker.HippyFreeMarkerConfigurer] - <ClassTemplateLoader for Spring macros added to FreeMarker configuration> 
2012-06-04 10:17:55,528 INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - <Mapped URL path [/configuration] onto handler 'configurationHandler'> 
2012-06-04 10:17:56,230 INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - <Mapped URL path [/job-configuration] onto handler '/job-configuration'> 
... 
2012-06-04 10:17:56,230 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Context initialization failed> 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/job-configuration.json': Cannot resolve reference to bean 'job-configurations' while setting bean property 'requestChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'job-configurations' is defined 

有人遇到過這個嗎?該應用程序依賴於一個簡單的彈簧批處理jar,它完全獨立工作,我期望它能從該工件中提取任何需要的工作bean。

+0

您是否定義了「job-configurations」bean?這就是Spring在這裏發生的錯誤。 –

+0

根據在已經提供的僞像中定義的彈簧管理文檔: \t \t \t \t \t org.springframework.batch \t \t \t 彈簧分批管理員資源 \t \t \t \t \t \t $ {spring.batch.resources.version} \t \t \t \t \t \t \t org.springframework.batch \t \t \t 彈簧批次管理經理 \t \t \t $ {spring.batch.resources。版本} \t \t Eddie

+0

到這一點我沒有任何定義configurationHandler,它只是使用已經由Spring Batch的管理代碼庫 – Eddie

回答

1

我向一些同事提出了這個問題,這似乎是我認爲春季批量管理員的設計中存在一個缺陷,違背了許多典型的Spring設計模式。

依賴的spring batch admin jar「知道太多」瞭解包括數據源在內的解決方案的上下文。問題在於,在一個體面的網絡應用程序中,數據源可以在運行時根據數字或環境變量(環境,數據中心,應用程序服務器)動態確定,並不像Dave Syer's(Mysql或HSQL)方法那麼簡單。我已經閱讀posts in spring論壇,但他支持這個問題,但是,與問題接近的侮辱。

如果批處理作業使用多個數據源(即源數據庫和目標數據庫),這會變得越來越複雜。並不像在webapp中加載數據源那麼簡單,因爲所有相關的bean都已經連接了Dave的HSQL驅動程序DS以及相關的.sql文件和init腳本。

這導致我基本上從批處理jar包括jobrepository(預期的),jobExplorer,jobService和其他幾個其他文件在META-INF/spring/batch /覆蓋目錄。每個文件都利用Spring 3.1的Profile命名空間來加載適當的數據源,並注入所有需要的bean。

+1

定義你可以發佈您的覆蓋文件的情況下的答案,請的人? – emeraldjava

+1

你能用一些代碼來解釋你的答案嗎?我面臨同樣的問題。 –

相關問題