Flowable 6.6.0 事件注册表用户指南 - 2 配置 - 2.5 JNDI 数据源配置

Flowable 6.6.0 用户指南相关文档下载


Flowable 6.6.0 事件注册表用户指南

目录

1 事件注册表介绍

2 配置

3 Flowable 事件注册表API

4 Spring集成
5 部署

6 REST API


有关Flowable的更多文档,参见:

《Flowable文档大全》


Flowable 6.6.0 事件注册表用户指南PDF版下载

请点击:《事件注册表用户指南 - 中文PDF精编版》


2.5 JNDI 数据源配置

By default, the database configuration for Flowable Event Registry is contained within the db.properties files in the WEB-INF/classes of each web application. This isn’t always ideal because it requires users to either modify the db.properties in the Flowable source and recompile the WAR file, or explode the WAR and modify the db.properties on every deployment.

默认情况下,Flowable事件注册表的数据库配置包含在每个WEB应用程序的WEB-INF/ classes中的db.properties文件中。这并不总是理想的,因为它需要用户在Flowable源代码中修改db.properties,并重新编译WAR文件,或者解压缩WAR并修改在每次部署中的db.properties。

By using JNDI (Java Naming and Directory Interface) to obtain the database connection, the connection is fully managed by the Servlet Container and the configuration can be managed outside the war deployment. This also allows more control over the connection parameters than what is provided by the db.properties file.

通过使用JNDI(Java命名和目录接口,Java Naming and Directory Interface)获得数据库连接,连接完全由Servlet容器(Servlet Container)管理,配置可以在war部署之外进行管理。这还允许对连接参数进行更好(对比db.properties文件)的控制。

2.5.1 配置

Configuration of the JNDI datasource will differ depending on what servlet container application you are using. The instructions below will work for Tomcat, but for other container applications, please refer to the documentation for your container app.

JNDI数据源的配置将根据您使用的servlet容器应用程序而有所不同。以下说明适用于Tomcat,但对于其他容器应用程序,请参阅容器应用程序的文档。

If using Tomcat, the JNDI resource is configured within $CATALINA_BASE/conf/[enginename]/[hostname]/[warname].xml (for the Flowable UI this will usually be $CATALINA_BASE/conf/Catalina/localhost/flowable-app.xml). The default context is copied from the Flowable WAR file when the application is first deployed, so if it already exists, you will need to replace it. To change the JNDI resource so that the application connects to MySQL instead of H2, for example, change the file to the following:

如果使用Tomcat,JNDI资源将在 C A T A L I N A B A S E / c o n f / [ e n g i n e n a m e ] / [ h o s t n a m e ] / [ w a r n a m e ] . x m l 中 配 置 ( 对 于 F l o w a b l e U I , 通 常 是 CATALINA_BASE/conf/[enginename]/[hostname]/[warname].xml中配置(对于Flowable UI,通常是 CATALINABASE/conf/[enginename]/[hostname]/[warname].xmlFlowableUICATALINA_BASE/conf/Catalina/localhost/flowable-app.xml). 默认上下文是在应用程序首次部署时从Flowable WAR文件复制的,因此如果它已经存在,则需要替换它。例如,要更改JNDI资源以便应用程序连接到MySQL而不是H2,请将文件更改为:


<?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/flowable-app">
        <Resource auth="Container"
            name="jdbc/flowableDB"
            type="javax.sql.DataSource"
            description="JDBC DataSource"
            url="jdbc:mysql://localhost:3306/flowable"
            driverClassName="com.mysql.jdbc.Driver"
            username="sa"
            password=""
            defaultAutoCommit="false"
            initialSize="5"
            maxWait="5000"
            maxActive="120"
            maxIdle="5"/>
        </Context>

2.5.2 JNDI 属性

To configure a JNDI Datasource, use the following properties in the properties file for the Flowable UI:
要配置JNDI数据源,请在Flowable UI的属性文件中使用以下属性:

  • spring.datasource.jndi-name=: the JNDI name of the Datasource.
  • datasource.jndi.resourceRef: Set whether the lookup occurs in a J2EE container, in other words, if the prefix “java:comp/env/” needs to be added if the JNDI name doesn’t already contain it. Default is “true”.
  • spring.datasource.jndi文件-name=:数据源的JNDI名称。
  • datasource.jndi.resourceRef:设置是否在J2EE容器中进行查找,换句话说,如果JNDI名称尚未包含前缀java:comp/env/,是否需要添加该前缀。默认值为“true”。

2.5.3 自定义属性

System properties can also be used in the flowable.eventregistry.cfg.xml by using them in the format ${propertyName:defaultValue}.

系统属性也可以用于flowable.eventregistry.cfg.xml,以 ${propertyName:defaultValue}格式使用它们。

<property name="jdbcUrl" value="${jdbc.url:jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000}" />
<property name="jdbcDriver" value="${jdbc.driver:org.h2.Driver}" />
<property name="jdbcUsername" value="${jdbc.username:sa}" />
<property name="jdbcPassword" value="${jdbc.password:}" />

Using this configuration if the property jdbc.url is available then it would be used for the jdbcUrl of the EventRegistryEngineConfiguration. Otherwise the value after the first : would be used.

It is also possible to define locations from where properties can be picked up from the system by using a bean of type org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.

Example configuration with custom location for properties

如果属性jdbc.url可以,则使用该配置,然后则它将用于EventRegistryEngineConfiguration的jdbcUrl。否则将使用第一个“: ”后面的值。
还可以通过使用类型为org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的bean来定义可以从系统中获取属性的位置。

属性的自定义位置配置示例

<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.xsd">

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="file:/opt/conf/flowable.properties" />
  </bean>

  <bean id="eventRegistryEngineConfiguration" class="org.flowable.eventregistry.impl.cfg.StandaloneEventRegistryEngineConfiguration">

    <property name="jdbcUrl" value="${jdbc.url:jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000}" />
    <property name="jdbcDriver" value="${jdbc.driver:org.h2.Driver}" />
    <property name="jdbcUsername" value="${jdbc.username:sa}" />
    <property name="jdbcPassword" value="${jdbc.password:}" />

    <property name="databaseSchemaUpdate" value="true" />

  </bean>

</beans>

With this configuration the properties would be first looked up in the /opt/conf/flowable.properties file.

使用此配置,将首先在/opt/conf/flowable.properties中查找属性文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月满闲庭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值