我找到了解决此问题的方法。由于无法注册Mbean,因此我们需要覆盖jmx-context.xml,该文件将扫描具有不同域名的jmx Mbean。
在/ meta-INF / spring / batch / override /目录下的具有覆盖上下文的批处理项目中的一个项目中创建jmx-
context.xml:覆盖用于扫描的mbean-export和用于集成Mbean的int-jmx:mbean-export,如下所示-
/meta-INF/spring/batch/override/jmx-context.xml-
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx" xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application.mybatch" server="mbeanServer" /> <context:mbean-export default-domain="spring.application.mybatch" server="mbeanServer" /></beans>
确保为该春季批处理项目更改具有唯一名称的默认域。实施此解决方案后,我使两个批处理应用程序在Weblogic域内的单个群集中同时运行。
重要的是,将jmx-context.xml作为/ appa-INF / spring / batch / override
/作为您在servlet.xml文件中导入的webapp-config.xml放置,以便配置管理控制台,并从该替代中导入所有*
.xml文件夹&可以用来覆盖任何默认配置。仅供参考,我在这里从spring-batch-admin-manager-resources
jar复制了webapp-config.xml的内容,应将其作为项目中的依赖项引入。
/org/springframework/batch/admin/web/resources/webapp-config.xml-
<?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"> <!-- Workaround for INT-1831 --> <bean id="dummy" /> <import resource="classpath*:/meta-INF/spring/batch/bootstrap*.xml" /> <import resource="classpath*:/meta-INF/spring/batch/override*.xml" /> <bean id="parameterUnpackerFilter" > <property name="prefix" value="unpack_"/> <property name="putEmptyParamsInPath" value="true"/> </bean></beans>
以防万一,如果您想知道我们将webapp-
config.xml导入哪里,我放下了servlet.xml的内容来配置批处理管理控制台,您在启动时将其加载到项目的web.xml中。
/WEB-INF/config/spring-beans/servlet.xml-
<?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-3.0.xsd"> <!-- Spring Batch Admin --> <import resource="classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml"/> <import resource="classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml"/> <bean id="resourceService" > <property name="servletPath" value="/batch" /> </bean></beans>



