# Spring Boot Separate DataSource Properties File

**URL:** <https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358>\
**Category:** Flowable Engine\
**Created:** [February 24, 2017, 4:01pm UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358 "2017-02-24T16:01:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisqaqov](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jisqaqov](https://forum.flowable.org/u/jisqaqov)\
**Post date:** [February 24, 2017, 4:01pm UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/1 "2017-02-24T16:01:25Z")

</div>

## Good day. First of all, Thank you guys for this BPM. Recently, we wanted to make app with bpm and found this open source light weight bpm. I know you had been working in alfresco activiti. I hope you are doing well.

So my problem is:  
I have an issue with spring boot. Sorry for the issue, i earlier asked for similar problem. Currently flowable bpm uses my default database configured in application.properties file, when i startup my app. Though i want bpm to use some **flowable.properties** file so it could save tables in separate datasource. Using **flowable.cgf.xml** file seems uneasy because beans are not autoinjected.  
Could you consider such _feature_, special properties file for datasource.  
I think it is crucial, because bpm tables and my tables are mixed in one database schema.  
In addition, i want beans to be autoinjected. However, at least could you provide an example.

---

<div class="post-metadata">

**Author:** ![kjonnala](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kjonnala](https://forum.flowable.org/u/kjonnala)\
**Post date:** [February 24, 2017, 11:05pm UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/2 "2017-02-24T23:05:12Z")

</div>

Have you tried using 2 beans, one for primary the other for activiti:

Something like :

```
  @Bean
  @Primary
  @ConfigurationProperties(prefix = "spring.datasource")
  public DataSource primaryDataSource() {
    return DataSourceBuilder
        .create()
        .url(dataSourceProperties.getUrl())
        .username(dataSourceProperties.getUsername())
        .password(dataSourceProperties.getPassword())
        .driverClassName(dataSourceProperties.getDriverClassName())
        .build();
  }

  @Bean
  @ConfigurationProperties(prefix = "spring.activiti.datasource")
  public DataSource activitiDataSource() {
    return DataSourceBuilder
        .create()
        .url(activitiDataSourceProperties.getUrl())
        .username(dataSourceProperties.getUsername())
        .password(dataSourceProperties.getPassword())
        .driverClassName(dataSourceProperties.getDriverClassName())
        .build();
  }
```

---

<div class="post-metadata">

**Author:** ![jisqaqov](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jisqaqov](https://forum.flowable.org/u/jisqaqov)\
**Post date:** [February 25, 2017, 5:20am UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/3 "2017-02-25T05:20:27Z")

</div>

Good idea. I should try it. However, properties file is far better approach, because you do not need to change source code.

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [February 26, 2017, 10:05am UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/4 "2017-02-26T10:05:53Z")

</div>

Adding the option to the flowable.properties file makes sense I think. But you are aware that this means you need a JTA transaction manager in Spring boot because you are working with multiple data sources from the same application, right? If you more transaction participants (like a message queue etc), then this makes sense anyway, but if you add the JTA transaction manager just because of handling multiple data sources, you might want to consider using the same database schema or separating the application in two parts if possible.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![jisqaqov](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jisqaqov](https://forum.flowable.org/u/jisqaqov)\
**Post date:** [February 26, 2017, 10:33am UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/5 "2017-02-26T10:33:15Z")

</div>

Hello. Yeah, that’s a quite complicated issue, i didn’t expect. You are right. May be the better approach at least is to use separate schema in one database, which is fine for us. That should work and can be configured through flowable.properties or in our application.properties file with **flowable.bpm.datasource** option.

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [February 28, 2017, 7:49am UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/6 "2017-02-28T07:49:02Z")

</div>

Hi,

Having a separate schema in one database still means having multiple DataSource connection pools on a Spring boot application level. So you would still need a JTA transaction manager to manage multiple data sources. Or you need to switch between schema’s on a connection pool level, but that requires some custom coding I think.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![eran](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@eran](https://forum.flowable.org/u/eran)\
**Post date:** [July 4, 2018, 12:32pm UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/7 "2018-07-04T12:32:04Z")

</div>

> [@tijs](#):
>
> Adding the option to the flowable.properties file makes sense I think

Hi tijs,  
Was it added to flowable.properties ? Is it possible to choose the correct data source via a properties file?  
If not, maybe there’s another way ? (maybe by extending a Flowable class?)

We would love an example if it’s possible.

Thanks.

---

<div class="post-metadata">

**Author:** ![sshenolikar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sshenolikar/32/2627_2.png) [@sshenolikar](https://forum.flowable.org/u/sshenolikar)\
**Post date:** [November 9, 2021, 9:50am UTC](https://forum.flowable.org/t/spring-boot-separate-datasource-properties-file/358/8 "2021-11-09T09:50:00Z")

</div>

Might be late to reply but we implemented it by using flowable properties.  
We are using Oracle DB which is used as the primary data source for the Spring boot project.  
To use flowable in a different schema, add following properties to your properties file -

```auto
> flowable.database-schema=<your schema name>
> flowable.database-schema-update=true

```

Hope this helps!
