spring batch admin 嵌入web访问

充子航
2023-12-01

、配置依赖

[html]  view plain  copy
  1. <dependency>  
  2.     <groupId>org.springframework.batch</groupId>  
  3.     <artifactId>spring-batch-admin-resources</artifactId>  
  4. </dependency>  
  5. <dependency>  
  6.     <groupId>org.springframework.batch</groupId>  
  7.     <artifactId>spring-batch-admin-manager</artifactId>  
  8. </dependency>  

2、配置web.xml

[html]  view plain  copy
  1. <context-param>  
  2.     <param-name>contextConfigLocation</param-name>  
  3.     <param-value>  
  4.         classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml   
  5.     </param-value>  
  6. </context-param>  
  7. <filter>  
  8.     <filter-name>shallowEtagHeaderFilter</filter-name>  
  9.     <filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>  
  10. </filter>  
  11. <filter-mapping>  
  12.     <filter-name>shallowEtagHeaderFilter</filter-name>  
  13.     <url-pattern>/*</url-pattern>  
  14. </filter-mapping>  

3、覆盖batch admin 配置[如果需要]

[html]  view plain  copy
  1. <!-- override -->  
  2. <bean id="jobExplorer"  
  3.     class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"  
  4.     p:dataSource-ref="dataSource" p:tablePrefix="PREFIX_" />  
  5. <!-- override -->  
  6. <bean id="jobService"  
  7.     class="org.springframework.batch.admin.service.SimpleJobServiceFactoryBean">  
  8.     <property name="jobRepository" ref="jobRepository" />  
  9.     <property name="jobLauncher" ref="jobLauncher" />  
  10.     <property name="jobLocator" ref="jobRegistry" />  
  11.     <property name="dataSource" ref="dataSource" />  
  12.     <property name="tablePrefix" value="PREFIX_" />  
  13. </bean>  

4、访问

http://ip:port/


5、注意事项

[html]  view plain  copy
  1. webapp-config.xml这个配置会引入spring batch 内部定义的jobRepository,注意覆盖问题  
 类似资料: