Spring Boot Embedded Derby无法在最新版本中工作。 [英] Spring boot Embedded Derby not working in the latest version.

查看:121
本文介绍了Spring Boot Embedded Derby无法在最新版本中工作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的春季启动项目中,我之前使用过Embedded derby。但是现在,当我通过Spring Initializr使用derby依赖关系创建项目时。我收到以下错误:
模式'SA'不存在
,后跟 org.hibernate.tool.schema.spi.CommandAcceptanceException:通过JDBC执行DDL错误声明

I have used Embedded derby earlier in my spring boot projects. But now when i created the project through Spring Initializr with the derby dependency. I get the below error : Schema 'SA' does not exist followed by org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement

当我尝试运行自己创建的早期项目时,Derby正常运行。
PFB早期项目的控制台:

When i tried running the earlier project that i had created, the Derby is working just fine. PFB the console for the earlier project :


2018-03-18 15:34:44.346 INFO 16560 --- [ restartedMain]
org.hibernate.cfg.Environment:HHH000021:字节码
提供者名称:javassist 2018-03-18 15:34:44.391信息16560 --- [
restartedMain] o.hibernate .annotations.common.Version:HCANN000001:
Hibernate Commons注释{5.0.1.Final} 2018-03-18 15:34:44.490
** INFO 16560 --- [restartedMain] org.hibernate .dialect.Dialect

:HHH000400:使用方言:org.hibernate.dialect.DerbyDialect
2018-03-18 15:34:44.497 WARN 16560 --- [restartedMain]
org.hibernate.dialect.DerbyDialect:HHH000430:DerbyDialect
方言已被弃用;使用特定于版本的方言
**代替2018-03-18 15:34:45.094 INFO 16560 --- [restartedMain]
org.hibernate.tool.hbm2ddl.SchemaExport:HHH000227:正在运行hbm2ddl
模式导出2018-03-18 15:34:45.099错误16560 --- [
restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport:HHH000389:
不成功:删除表书2018-03-18 15:34:45.099错误16560 ---
[restartMainMain] org.hibernate.tool.hbm2ddl.SchemaExport:模式
'SA'不存在2018-03-18 15: 34:45.129 WARN 16560 --- [[
restartedMain] ohengine.jdbc.spi.SqlExceptionHelper:SQL警告
代码:10000,SQLState:01J01 2018-03-18 15:34:45.129 WARN 16560- -[[
restartedMain] ohengine.jdbc.spi.SqlExceptionHelper:未创建数据库
'memory:testdb',而是建立了与现有数据库
的连接。 2018-03-18 15:34:45.129信息16560--[restartedMain]
org.hibernate.tool.hbm2ddl.SchemaExport:HHH000230:模式导出
完成2018-03-18 15:34: 45.152信息16560--[restartedMain]
j.LocalContainerEntityManagerFactoryBean:为持久性单元'default'初始化的JPA
EntityManagerFactory

2018-03-18 15:34:44.346 INFO 16560 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-03-18 15:34:44.391 INFO 16560 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2018-03-18 15:34:44.490 **INFO 16560 --- [ restartedMain] org.hibernate.dialect.Dialect
: HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect 2018-03-18 15:34:44.497 WARN 16560 --- [ restartedMain] org.hibernate.dialect.DerbyDialect : HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects ** instead 2018-03-18 15:34:45.094 INFO 16560 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export 2018-03-18 15:34:45.099 ERROR 16560 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: drop table book 2018-03-18 15:34:45.099 ERROR 16560 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Schema 'SA' does not exist 2018-03-18 15:34:45.129 WARN 16560 --- [ restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 10000, SQLState: 01J01 2018-03-18 15:34:45.129 WARN 16560 --- [ restartedMain] o.h.engine.jdbc.spi.SqlExceptionHelper : Database 'memory:testdb' not created, connection made to existing database instead. 2018-03-18 15:34:45.129 INFO 16560 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete 2018-03-18 15:34:45.152 INFO 16560 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'

我当前具有嵌入式derby的春季引导的控制台日志:

The Console Log for my current spring boot with embedded derby :


2018-03-18 15:42:23.234 INFO 11312- -[main]
com.zaxxer.hikari.HikariDataSource:HikariPool-1-Starting ...
2018-03-18 15:42:23.237 WARN 11312 --- [main]
** com.zaxxer.hikari.util.DriverDataSource:未注册
driverClassName = org.apache.derby.jdbc.EmbeddedDriver的驱动程序,
尝试直接实例化。 2018-03-18 15:42:23.844信息11312 --- [
** main] com.zaxxer.hikari.pool.PoolBase:HikariPool-1-驱动程序
不支持获取/设置网络连接超时。 (功能未实现
:没有详细信息。)2018-03-18 15:42:23.847 INFO 11312 --- [

main] com.zaxxer.hikari.HikariDataSource:HikariPool-1-开始
完成。 2018-03-18 15:42:23.937信息11312 --- [main]
j.LocalContainerEntityManagerFactoryBean:为持久性单元'default'构建JPA容器
EntityManagerFactory 2018-03-18
15 :42:23.969 INFO 11312 --- [main]
o.hibernate.jpa.internal.util.LogHelper:HHH000204:处理
PersistenceUnitInfo [名称:默认...] 2018-03-18 15 :42:24.136
INFO 11312 --- [main] org.hibernate.Version

:HHH000412:Hibernate Core {5.2.14.Final} 2018-03-18 15:42:24.138
INFO 11312 --- [main] org.hibernate.cfg.Environment

:HHH000206:hibernate.properties找不到2018-03-18 15:42:24.199
INFO 11312 --- [main]
o.hibernate.annotations.common.Version:HCANN000001:Hibernate
Commons Annotations {5.0.1.Final} 2018-03-18 15:42:24.380 INFO 11312
--- [main] org.hibernate.dialect.Dialect:HHH000400:使用方言:org.hibernate.d ialect.DerbyTenSevenDialect
2018-03-18 15:42:25.572 WARN 11312 --- [main]
ohtsiExceptionHandlerLoggedImpl:GenerationTarget
遇到异常接受命令:通过JDBC $ b $执行DDL错误b语句

2018-03-18 15:42:23.234 INFO 11312 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2018-03-18 15:42:23.237 WARN 11312 --- [ main] **com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.apache.derby.jdbc.EmbeddedDriver was not found, trying direct instantiation. 2018-03-18 15:42:23.844 INFO 11312 --- [ ** main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (Feature not implemented: No details.) 2018-03-18 15:42:23.847 INFO 11312 --- [
main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2018-03-18 15:42:23.937 INFO 11312 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-03-18 15:42:23.969 INFO 11312 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-03-18 15:42:24.136 INFO 11312 --- [ main] org.hibernate.Version
: HHH000412: Hibernate Core {5.2.14.Final} 2018-03-18 15:42:24.138 INFO 11312 --- [ main] org.hibernate.cfg.Environment
: HHH000206: hibernate.properties not found 2018-03-18 15:42:24.199 INFO 11312 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2018-03-18 15:42:24.380 INFO 11312 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.DerbyTenSevenDialect 2018-03-18 15:42:25.572 WARN 11312 --- [ main] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException:错误
通过
org.hibernate.tool上的JDBC语句执行DDL。 schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
〜[hibernate-core-5.2.14.Final.jar:5.2.14.Final] at
org.hibernate.tool .schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)
[hibernate-core-5.2.14.Final.jar:5.2.14.Final]

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final] at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]

我可以发现两者之间的区别是,在当前日志(abv日志)中,它表示
com.zaxxer.hikari.util.DriverDataSource:
driverClassName = org.apache.derby.jdbc.EmbeddedDriver的已注册驱动程序不是und,
尝试直接实例化。

The difference i can find between the two is that in the current log(abv log) it says that the com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.apache.derby.jdbc.EmbeddedDriver was not found, trying direct instantiation.

让我知道我们是否需要配置除以下依赖项之外的其他功能以启用此德比。注意-除了上一个项目中的Maven依赖项,我没有做其他事情。

Let me know if we need to configure something apart from the below dependency for enabling this derby. Note- I dint do anything apart from maven dependency in the previous project.

Maven依赖项:

<dependency>
 <groupId>org.apache.derby</groupId>            
 <artifactId>derby</artifactId>
 <scope>runtime</scope>         
 </dependency>


推荐答案

请根据需要配置JPA配置。我的配置如下。您需要在application.properties文件中添加以下配置。

Please configure you JPA Configuration as per your requirement. I've configured as below. You need to add below configuration in application.properties file.

# PROFILES
spring.profiles.active=dev
# JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database=default
spring.jpa.show-sql=true
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.continue-on-error=false
spring.datasource.generate-unique-name=false

这篇关于Spring Boot Embedded Derby无法在最新版本中工作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆