12-22-2016 02:00 PM
I have a spring boot application with activiti integrated via org.acitviti.spring-boot-starter-basic.
I created the activiti tables via sql scripts. When I start spring boot, activiti complains that the tables already exist. So I added the following code to potentially stop jpa from complaining the tables exist:
@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. How can I configure activiti/spring such that the tables aren't created on spring startup?
01-05-2017 11:34 AM
I imagine since you are using the spring boot starters, that you are using Community Edition. If not, please let me know as the answer is different for Community Edition and Enterprise Edition.
In order to access the process engine configuration when Activiti is initialized, you need to create a bean/component that implements the org.activiti.spring.boot.ProcessEngineConfigurationConfigurer interface.
e.g.
@Component public class MyProcessEngineCfgConfigurer
implements ProcessEngineConfigurationConfigurer {
public void configure( SpringProcessEngineConfiguration springProcessEngineConfiguration) {
... // This is where we tweak the process engine configuration
}
}
The Spring boot starter AbstractProcessEngineAutoConfiguration class will look for this bean and if present will call the configure() method on it as soon as the SpringProcessEngineConfiguration is constructed.
The following github thread talks about this feature: Unclear how to configure activiti · Issue #5 · jbarrez/spring-boot-with-activiti-example · GitHub
Hope this helps,
Greg
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.