我有一个使用Spring Batch和Spring MVC的应用程序。我能够将Spring Batch Admin部署为单独的战争,并将其用于我的应用程序使用的同一个数据库,尽管我想将它集成到我自己的应用程序中,也可能修改一些视图。将Spring批处理管理集成到现有应用程序中
有没有一种简单的方法来做到这一点,还是我必须把它叉起来,并从那里?
我有一个使用Spring Batch和Spring MVC的应用程序。我能够将Spring Batch Admin部署为单独的战争,并将其用于我的应用程序使用的同一个数据库,尽管我想将它集成到我自己的应用程序中,也可能修改一些视图。将Spring批处理管理集成到现有应用程序中
有没有一种简单的方法来做到这一点,还是我必须把它叉起来,并从那里?
根据thread显然有一个简单的方法;
在web.xml
定义的DispatcherServlet批次管理:
<servlet>
<servlet-name>Batch Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Batch Servlet</servlet-name>
<url-pattern>/batch/*</url-pattern>
</servlet-mapping>
为resourceService添加替代根appContext:
<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
修改standard.ftl
春季批次管理员-resources-1.2.0-RELEASE.jar以反映网址:
<#assign url><@spring.url relativeUrl="${servletPath}/resources/styles/main.css"/></#assign>
如果您正在使用Spring-batch-admin 1.2.1
,你不必修改standard.ftl
文件。您应该添加servlet-config.xml
和webapp-config.xml
文件从org/springframework/batch/admin/web/resources
。以下是具体步骤(重复一次):
<servlet>
<servlet-name>Batch Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml,classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
在applicationContext
添加resourceService
豆:
<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
根据这个问题的答案,'resourceService'定义应该放在META-INF \ spring \ batch \ override'中。 http://stackoverflow.com/questions/23880396/batch-admin-console-dispatcherservlet-using-internalresourceviewresolver-inste – Stewart
取而代之的参考弹簧批次管理XML文件是这样的:
<param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml</param-value>
你也可以参考你自己的XML文件
<param-value>classpath:eregister-spring-admin-servlet.xml</param-value>
含somethink这样的:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<import resource="classpath*:/META-INF/spring/batch/servlet/resources/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/servlet/manager/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/servlet/override/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/bootstrap/**/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/override/**/*.xml" />
<!-- Override de standard locatie van spring batch admin resources -->
<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
<bean id="parameterUnpackerFilter" class="org.springframework.batch.admin.web.filter.ParameterUnpackerFilter">
<property name="prefix" value="unpack_"/>
<property name="putEmptyParamsInPath" value="true"/>
</bean>
</beans>
我有嵌入Spring Batch的管理员到我的应用程序被打包为一个jar文件。我这样做是因为这个应用程序已经存在,我使用J2SE运行它,而不是像Tomcat那样的servlet容器。此外,我不太喜欢为批处理作业部署Web服务器/ servlet容器的想法。 Spring Batch Admin应用程序是一个很好的参考实现,几乎所有的接口都可以通过Spring DI使用自定义类来替换。而且所有UI都是模板驱动的。 因此,我提取了相关资源并使用我的应用程序启动的嵌入式Jetty服务器运行控制台。实际上,这已经将应用程序内的servlet容器内的应用程序翻转为servlet容器。
屏幕截图在这里:https://github.com/regunathb/Trooper/wiki/Trooper-Batch-Web-Console
源,配置资源等在这里:https://github.com/regunathb/Trooper/tree/master/batch-core(检查/ src目录/主/资源/ WEB-INF文件夹的网络相关CONFIGS和资源)
+1你答案链接在这里:http://forum.springsource.org/showthread.php?116685-Spring-Batch-Admin-App-fails-to-create-configuration-bean – opyate
你可以发布你的pom.xml的细节在哪里你声明spring-batch-admin jar文件的依赖关系? – emeraldjava