hi,all:
I want to use activiti7 with mysql, but I can not find the user guide.
@xxf0925 hi there.. thanks for reporting this issue..
can you explain how and where are you trying to use MySQL?
Are you creating a simple spring boot app with the activiti-spring-boot-starter? or are you trying the activiti cloud approach?
I create a spring boot with activiti-spring-boot-starter,but i can not find the example or sql in the activiti-examples and guide.
I have the same problem,Any examples for mysql?
Usually you need to provide the jdbc driver for MySQL like we do here for postgresql:
And then just add your JDBC connection parameters for spring to be able to connect:
That should configuration should work in the activiti-example projects. If it doesn't please let us know.
Join mysql-connector-java dependency and add JDBC connection parameters for spring ,### but it doesn't work.
The exception log is as follows:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-21 09:29:09.461 ERROR 15276 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 0 of method springProcessEngineConfiguration in org.activiti.spring.boot.ProcessEngineAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'dataSource' in 'JndiDataSourceAutoConfiguration' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' in 'XADataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:
Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.
thx,my code works, I think the only problem is that the engine does not create table automatically with mysql but h2, I execute the sql in org/activiti/db/create/activiti.mysql.create.engine.sql and org/activiti/db/create/activiti.mysql.create.history.sql.
My pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<activiti-dependencies.version>7.0.0.Beta5</activiti-dependencies.version>
</properties>
...
<!--<dependency>-->
<!--<groupId>com.h2database</groupId>-->
<!--<artifactId>h2</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
@xxf0925 thanks for your feedback.
Can you try removing
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
and can you please test with
<activiti-dependencies.version>7.0.0.GA</activiti-dependencies.version>
We can review why the tables are not being generated for mysql, there must be something else missing, because in our tests with PostgreSQL we see no problems.
It will be great if from this issue we can create an example that we can add to the docs.
@xxf0925 I can see this one missing https://github.com/Activiti/example-runtime-bundle/blob/master/charts/example-runtime-bundle/templates/deployment.yaml#L75
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=create-drop
Can you try those to see if that helps?
I think I find the bug.
In org/activiti/engine/impl/db/DbSqlSession, you use the databaseMetaData.getTables to find whether the database activiti existed, but the code get null of catalog from dbSqlSessionFactory because mysql use Schema for database name not catalog. And mysql use nullCatalogMeansCurrent to control the default database name, if the catalog is null, mysql will scan all databases. If other database has the same table ACT_RU_EXECUTION, the result will be true.
In mysql-connector-java 5.x nullCatalogMeansCurrent is true by default, but 6.x the value is false, so the solution is setting the nullCatalogMeansCurrent true
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/activiti?nullCatalogMeansCurrent=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
spring-boot-starter-jdbc and mysql-connector-java are needed if you do not want to use mybatis.
I think the best way is fixing the bug which to get the right database name from mysql.
Most helpful comment
I think I find the bug.
In
org/activiti/engine/impl/db/DbSqlSession, you use thedatabaseMetaData.getTablesto find whether the database activiti existed, but the code get null ofcatalogfrom dbSqlSessionFactory because mysql use Schema for database name not catalog. And mysql usenullCatalogMeansCurrentto control the default database name, if the catalog is null, mysql will scan all databases. If other database has the same table ACT_RU_EXECUTION, the result will be true.In mysql-connector-java 5.x
nullCatalogMeansCurrentis true by default, but 6.x the value is false, so the solution is setting the nullCatalogMeansCurrent truespring-boot-starter-jdbc and mysql-connector-java are needed if you do not want to use mybatis.
I think the best way is fixing the bug which to get the right database name from mysql.