【发布时间】:2016-01-11 01:42:45
【问题描述】:
出现“无法验证新建立的连接”错误。
我搜索并阅读了与此错误相关的每个问题。但是没找到解决办法。
我正在使用spring-boot-starter-data-jpa。
它在使用 Postgresql 时没有任何错误。但是我想用嵌入式数据库!!!
application.properties:
#We don't need JMX here - disabling it allows for faster startup
spring.jmx.enabled=false
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.driver-class-name=org.hsqldb.jdbcDriver
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
spring.datasource.url=jdbc:hsqldb:file:${user.home}/db/data;user=sa;password=123;
spring.datasource.username=sa
spring.datasource.password=123
MainApplication 类的标题:
@ComponentScan(value = {"db", "app", "ui"})
@EnableJpaRepositories(basePackages = "db")
@EntityScan(basePackages = "db")
@EnableTransactionManagement
@SpringBootApplication
此错误仅在我使用嵌入式数据库(至少是 Derby、HSQLDB)时引发,并非总是如此。有时它会正常启动,查找并保存实体时不会出错,但有时会在等待一段时间后或在成功交易后立即发生。
我该如何解决这个问题?
【问题讨论】:
-
“这个错误……” 哪一个?将其添加到您的问题中。
-
对不起,这个错误是“无法验证新建立的连接”
标签: java spring postgresql spring-boot spring-data-jpa