我尝试将使用自动配置的MariaDB数据库的Spring Boot应用程序部署到Cloud Foundry平台,我的应用程序在Pivotal CFY中按预期工作,但是当我将其部署到内部CFY平台时,我遇到了错误与休眠方言有关。
INFO 13 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
....
Caused by: java.sql.SQLSyntaxErrorException: (conn=1279230) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'type=MyISAM' at line 1
我想排除Hibernate方言的spring boot自动配置以使用用户定义的方言。
我使用以下命令在application.properties中指定了我的方言和jpa属性:
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect.storage_engine=innodb
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
和hibernate.properties中的
hibernate.dialect = org.hibernate.dialect.MariaDB10Dialect
但是当我运行我的应用程序时,我在日志中看到,弹簧自动配置会覆盖我指定的方言。
2018-11-07T11:17:05.57+0100 [APP/PROC/WEB/0] OUT 2018-11-07 10:17:05.577 INFO 13 --- [ main] org.hibernate.cfg.Environment : HHH000205: Loaded properties from resource hibernate.properties: {hibernate.dialect=org.hibernate.dialect.MariaDB10Dialect, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=org.mariadb.jdbc.Driver}
2018-11-07T11:17:06.37+0100 [APP/PROC/WEB/0] OUT 2018-11-07 10:17:06.368 INFO 13 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect