Add Custom Mybatis XML Mapper using java configuration as separate jar file

Hello,

I would like to add my custom REST APIs. So I have to add CustomMybatisXMLMapper in process engine configuration. I have created a jar file in which spring.factories contains a class to be loaded as configuration. Below is the class

@Configuration
// Makes sure that this configuration will be processed last by Spring Boot
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
// The configuration will only be used when the ProcessEngine bean is present
@ConditionalOnBean(type = "org.flowable.engine.ProcessEngine")
public class FlowableWorkflowEngineConfig {

    @Bean
    public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customProcessEngineConfigurationConfigurer() {
        return engineConfiguration -> {
            org.apache.ibatis.logging.LogFactory.useSlf4jLogging();
            // You can use this to add extra configuration to the process engine
            if (engineConfiguration.getCustomMybatisXMLMappers() == null) {
                engineConfiguration.setCustomMybatisXMLMappers(new HashSet<>());
            }
            engineConfiguration.getCustomMybatisXMLMappers().add("mappers/CustomTask.xml");
        };
    }

}

When I run query it throws error Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for.

Now if I define the mapper in flowable-default.properties file using following setting then it works.

flowable.customMybatisXMLMappers[0]=mappers/CustomTask.xml

So is there a way to initialize CustomMybatisXMLMapper configuration without updating flowable-default.properties file?

Thanks,
Dhaval

1 Like