11

SpringBatchとSpringMVCを使用するアプリケーションがあります。Spring Batch Adminを別の戦争としてデプロイし、アプリケーションが使用するのと同じDBに対して使用することができますが、それを自分のアプリケーションに統合したいのですが、ビューの一部も変更する可能性があります。

これを行う簡単な方法はありますか、それともフォークしてそこから移動する必要がありますか?

4

4 に答える 4

14

どうやらこのスレッドによると簡単な方法があります;

  • バッチ管理用のDispatcherServletを次の場所で定義し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>
    
  • ルートappContextにresourceServiceのオーバーライドを追加します。

    <bean id="resourceService"
    class="org.springframework.batch.admin.web.resources.DefaultResourceService">
        <property name="servletPath" value="/batch" />
    </bean> 
    
  • standard.ftl次のURLを反映するように、spring-batch-admin-resources-1.2.0-RELEASE.jarで変更します。

    <#assign url><@spring.url relativeUrl="${servletPath}/resources/styles/main.css"/></#assign>

于 2011-06-24T09:50:24.377 に答える
7

を使用している場合は、ファイルSpring-batch-admin 1.2.1を変更する必要はありませんstandard.ftlservlet-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>

resourceServiceあなたの豆を追加しますapplicationContext

<bean id="resourceService"
class="org.springframework.batch.admin.web.resources.DefaultResourceService">
    <property name="servletPath" value="/batch" />
</bean>
于 2012-06-15T17:11:03.890 に答える
4

jarファイルとしてパッケージ化されたアプリケーションにSpringBatchadminを埋め込みました。これを行ったのは、このアプリがすでに存在し、Tomcatのようなサーブレットコンテナではなく、J2SEを使用して実行したためです。さらに、バッチジョブ用にWebサーバー/サーブレットコンテナをデプロイする必要があるという考えはあまり好きではありませんでした。Spring Batch Adminアプリケーションは優れたリファレンス実装であり、ほとんどすべてのインターフェイスは、SpringDIを介してカスタムクラスを使用して置き換えることができます。さらに、すべてのUIはテンプレート駆動型でした。したがって、関連するリソースを抽出し、アプリケーションが起動する組み込みのJettyサーバーを使用してコンソールを実行しました。これにより、事実上、包含がサーブレットコンテナ内のアプリからアプリ内のサーブレットコンテナに反転しました。

スクリーンショットはこちら:https ://github.com/regunathb/Trooper/wiki/Trooper-Batch-Web-Console

ソース、構成リソースなどはここにあります:https ://github.com/regunathb/Trooper/tree/master/batch-core (Web関連の構成とリソースについては/ src / main / resources / WEB-INFフォルダーを確認してください)

于 2012-12-18T04:31:12.653 に答える
3

次のようなSpringBatchAdminXMLファイルを参照する代わりに:

<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>

このような何かを含む:

<?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>
于 2012-12-05T14:59:27.360 に答える