各位大神帮忙看看 SpringBoot集成H2初始化Scheam not found [90079-199]?
使用Springboot集成H2 内嵌模式, 使用时异常如下:
2019-04-01 17:07:37,367 DEBUG (DataSourceUtils.java:114)- Fetching JDBC Connection from DataSource
2019-04-01 17:07:37,367 DEBUG (HikariConfig.java:1020)- HCBIH2MetaDataHikariCP - configuration:
2019-04-01 17:07:37,367 DEBUG (HikariConfig.java:1052)- allowPoolSuspension.............false
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- autoCommit......................true
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- catalog.........................none
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- connectionInitSql...............none
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- connectionTestQuery............."SELECT 1 FROM DUAL"
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- connectionTimeout...............30000
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- dataSource......................none
2019-04-01 17:07:37,368 DEBUG (HikariConfig.java:1052)- dataSourceClassName.............none
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- dataSourceJNDI..................none
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- dataSourceProperties............{password=<masked>}
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- driverClassName................."org.h2.Driver"
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- healthCheckProperties...........{}
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- healthCheckRegistry.............none
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- idleTimeout.....................30000
2019-04-01 17:07:37,369 DEBUG (HikariConfig.java:1052)- initializationFailTimeout.......1
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- isolateInternalQueries..........false
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- jdbcUrl.........................jdbc:h2:~/H2Data/metadata;AUTO_SERVER=TRUE
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- leakDetectionThreshold..........0
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- maxLifetime.....................1800000
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- maximumPoolSize.................15
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- metricRegistry..................none
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- metricsTrackerFactory...........none
2019-04-01 17:07:37,370 DEBUG (HikariConfig.java:1052)- minimumIdle.....................5
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- password........................<masked>
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- poolName........................"HCBIH2MetaDataHikariCP"
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- readOnly........................false
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- registerMbeans..................false
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- scheduledExecutor...............none
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- schema.........................."classpath:sql/h2.sql"
2019-04-01 17:07:37,371 DEBUG (HikariConfig.java:1052)- threadFactory...................internal
2019-04-01 17:07:37,372 DEBUG (HikariConfig.java:1052)- transactionIsolation............default
2019-04-01 17:07:37,372 DEBUG (HikariConfig.java:1052)- username........................"sa"
2019-04-01 17:07:37,372 DEBUG (HikariConfig.java:1052)- validationTimeout...............5000
2019-04-01 17:07:37,373 INFO (HikariDataSource.java:110)- HCBIH2MetaDataHikariCP - Starting...
2019-04-01 17:07:56,908 DEBUG (QuartzSchedulerThread.java:291)- batch acquisition of 0 triggers
2019-04-01 17:08:00,859 DEBUG (HikariPool.java:411)- HCBIMysqlMetaDataHikariCP - Before cleanup stats (total=6, active=0, idle=6, waiting=0)
2019-04-01 17:08:00,859 DEBUG (HikariPool.java:411)- HCBIMysqlMetaDataHikariCP - After cleanup stats (total=6, active=0, idle=6, waiting=0)
2019-04-01 17:08:12,638 DEBUG (PoolBase.java:129)- HCBIH2MetaDataHikariCP - Closing connection conn17: url=jdbc:h2:~/H2Data/metadata user=SA: (Failed to create/setup connection)
2019-04-01 17:08:12,654 DEBUG (HikariPool.java:487)- HCBIH2MetaDataHikariCP - Cannot acquire connection from data source
org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "classpath:sql/h2.sql" not found [90079-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.engine.Database.getSchema(Database.java:2015)
at org.h2.engine.Session.setCurrentSchemaName(Session.java:1336)
at org.h2.jdbc.JdbcConnection.setSchema(JdbcConnection.java:2014)
at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:432)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:374)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:612)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:669)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:712)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:763)
at org.hcbi.security.service.DbUserDetailService.loadUsersByUsername(DbUserDetailService.java:20)
at org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl.loadUserByUsername(JdbcDaoImpl.java:184)
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:108)
at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:144)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:175)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:200)
at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
数据源配置文件
# 第二数据源(嵌入式)配置开始
secondary.datasource.type=com.zaxxer.hikari.HikariDataSource
secondary.datasource.driver-class-name=org.h2.Driver
secondary.datasource.jdbc-url=jdbc:h2:~/H2Data/metadata;AUTO_SERVER=TRUE
secondary.datasource.username=sa
secondary.datasource.password=
secondary.datasource.platform=h2
secondary.datasource.schema=classpath:sql/h2.sql
secondary.datasource.data=classpath:sql/sample_data.sql
secondary.datasource.initialization-mode=always
secondary.datasource.connection-timeout=30000
secondary.datasource.auto-commit=true
secondary.datasource.max-lifetime=1800000
secondary.datasource.pool-name=HCBIH2MetaDataHikariCP
secondary.datasource.minimum-idle=5
secondary.datasource.connection-test-query=SELECT 1 FROM DUAL
secondary.datasource.maximum-pool-size=15
secondary.datasource.idle-timeout=30000
数据库初始化文件存放目录结构:
版本:
SpringBoot 2.1.3.RELEASE
h2 1.4.199
尝试了网上几种方式都无效.......
各位大神帮忙看看....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
h2版本降到1.4.197试一下
试了, clean update 都不行, 这个问题从昨天困扰我至今
执行一下mvn clean compile 试试。
顶一顶