I have an application which uses Spring Batch and Spring MVC. I am able to deploy Spring Batch Admin as a separate war and use it against the same DB my application uses, though I would like to integrate it into my own application, possibly modify some of the views as well.
Is there an easy way to do this or do I have to fork it and go from there?
There is an easy way apparently according to this thread;
Define a DispatcherServlet for Batch Admin in web.xml
:
<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>
Add an override for resourceService in the root appContext:
<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
Modify standard.ftl
in spring-batch-admin-resources-1.2.0-RELEASE.jar to reflect the URL:
<#assign url><@spring.url relativeUrl="${servletPath}/resources/styles/main.css"/></#assign>
If you are using Spring-batch-admin 1.2.1
, you don't have to modify standard.ftl
file. And you should add both servlet-config.xml
and webapp-config.xml
files from org/springframework/batch/admin/web/resources
. Here are the steps (repeated again):
<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>
Add resourceService
bean in your applicationContext
:
<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch" />
</bean>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With