cancel
Showing results for 
Search instead for 
Did you mean: 

How to set database table prefix when using Spring Boot?

jubedus
Champ in-the-making
Champ in-the-making
Hello Experts,

  I am trying to switch my Activiti 5.19.0 + Spring Boot application to Oracle database. All Activiti tables have been already created by DBA in a dedicated schema. According to documentation, I need to specify database table prefix in order for Activiti queries to run successfully. Otherwise, Activiti doesn't find the tables. I tried adding the following entries in application.properties.

spring.activiti.databaseSchema=GM_ACTIVITI
spring.activiti.databaseTablePrefix=GM_ACTIVITI.
spring.activiti.tablePrefixIsSchema=true

As I'm debugging through Activiti code (ProcessEngineConfiguration), I can see that configuration for databaseSchema is applied, but databaseTablePrefix and tablePrefixIsSchema are not. If I set databaseTablePrefix and databaseTablePrefix during run-time then queries are executed fine.

Any idea how to configure databaseTablePrefix and tablePrefixIsSchema in application.properties?

Thanks a lot in advance!
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
So just to make sure: you were able to make it work by changing the process engine config programmatically?
In that case, it might simply be that the properties are not read and passed into the engine.

jubedus
Champ in-the-making
Champ in-the-making
Hi Joram,

  Thanks for your reply!
 
  No, I'm still trying to figure out how to change the process engine config programmatically. I was able the change the values of the process engine config as I was debugging through the application in Eclipse. Do you have an example of how to change process engine config in a Spring Boot application on start-up? Thanks a lot in advance!

Since table prefix is not listed in ActivitiProperties, does it mean it can't be set through configuration?

jbarrez
Star Contributor
Star Contributor
There is a configurer class you can use: https://github.com/Activiti/Activiti/blob/master/modules/activiti-spring-boot/spring-boot-starters/a...

Indeed, since it's not in ActivitiProperties, it's not read and passed.

shere_khan_
Champ in-the-making
Champ in-the-making

Have you made any progress on this? I'm having a similar issue. I created the activiti tables via sql scripts, and to stop activiti from complaining that the tables exist when I start spring boot, I added the following code:

@Bean
StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration() {
StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration =
new StandaloneProcessEngineConfiguration();
standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate("true");
return standaloneProcessEngineConfiguration;
}

But now I get the below stack trace:

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.activiti.engine.ProcessEngineConfiguration] is defined: expected single matching bean but found 2: standaloneProcessEngineConfiguration,springProcessEngineConfiguration
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1126)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 25 more

Basically, the bean is already defined by default and I need to figure out a clean workaround for this. Are you getting that same exception by any chance?