当前位置: 首页 > 知识库问答 >
问题:

带有Spring Boot错误的H2嵌入式数据库自动配置

黄沈浪
2023-03-14
2016-10-19 22:05:25.818  INFO 14104 --- [           main] com.example.SpringDemoApplication        : Starting SpringDemoApplication on BOM1-LPMP12AS7U with PID 14104 (D:\workspace\eclipse\SpringDemo\target\classes started by e3028311 in D:\workspace\eclipse\SpringDemo)
2016-10-19 22:05:25.822  INFO 14104 --- [           main] com.example.SpringDemoApplication        : No active profile set, falling back to default profiles: default
2016-10-19 22:05:25.904  INFO 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@543e710e: startup date [Wed Oct 19 22:05:25 IST 2016]; root of context hierarchy
2016-10-19 22:05:27.609  INFO 14104 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ece75ca4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-19 22:05:28.474  INFO 14104 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-10-19 22:05:28.490  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-10-19 22:05:28.491  INFO 14104 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.37
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2759 ms
2016-10-19 22:05:29.055  INFO 14104 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-19 22:05:29.060  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-19 22:05:29.131  WARN 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2016-10-19 22:05:29.146  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2016-10-19 22:05:29.169 ERROR 14104 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1218) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at com.example.SpringDemoApplication.main(SpringDemoApplication.java:27) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 26 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1199) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1123) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1021) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 28 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 40 common frames omitted
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 41 common frames omitted

2016-10-19 22:05:29.173  INFO 14104 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/D:/workspace/eclipse/SpringDemo/target/classes/, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.8.RELEASE/spring-boot-starter-web-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.8.RELEASE/spring-boot-starter-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot/1.3.8.RELEASE/spring-boot-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.8.RELEASE/spring-boot-autoconfigure-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.8.RELEASE/spring-boot-starter-logging-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.8.RELEASE/spring-boot-starter-tomcat-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.37/tomcat-embed-core-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.37/tomcat-embed-el-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.37/tomcat-embed-logging-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.37/tomcat-embed-websocket-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.8.RELEASE/spring-boot-starter-validation-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/e3028311/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.7/jackson-databind-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.7/jackson-annotations-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.7/jackson-core-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-web/4.2.8.RELEASE/spring-web-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aop/4.2.8.RELEASE/spring-aop-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-beans/4.2.8.RELEASE/spring-beans-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-context/4.2.8.RELEASE/spring-context-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-webmvc/4.2.8.RELEASE/spring-webmvc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-expression/4.2.8.RELEASE/spring-expression-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-core/4.2.8.RELEASE/spring-core-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.3.8.RELEASE/spring-boot-starter-data-jpa-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.3.8.RELEASE/spring-boot-starter-aop-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/e3028311/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/e3028311/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-jpa/1.9.5.RELEASE/spring-data-jpa-1.9.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-commons/1.11.5.RELEASE/spring-data-commons-1.11.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-orm/4.2.8.RELEASE/spring-orm-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-tx/4.2.8.RELEASE/spring-tx-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aspects/4.2.8.RELEASE/spring-aspects-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.3.8.RELEASE/spring-boot-starter-jdbc-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.0.37/tomcat-jdbc-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-juli/8.0.37/tomcat-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-jdbc/4.2.8.RELEASE/spring-jdbc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/com/h2database/h2/1.4.192/h2-1.4.192.jar]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>SpringDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SpringDemo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.8.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>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>
package com.example;



import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
@EnableAutoConfiguration
public class SpringDemoApplication {


    public static void main(String[] args) {
        SpringApplication.run(SpringDemoApplication.class, args);


    }


}

请在此查看结构。

共有1个答案

濮阳烨然
2023-03-14

我也遇到了同样的问题,我发现它是由损坏的H2依赖项的JAR文件引起的。请参阅有关损坏的罐子的链接

您要做的是删除.m2 maven本地存储库中与h2相关的jar文件。例如,我已经删除了以下目录;

C:\Users\<user>\.m2\repository\com\h2database\

我已经做了一个maven清理,所有的构建二进制文件都删除了,输出如下,没有什么特别的;

D:\SpringSTS\sts-tezgah\conquisitio>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building conquisitio 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ conquisitio ---
[INFO] Deleting D:\SpringSTS\sts-tezgah\conquisitio\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.825 s
[INFO] Finished at: 2017-10-07T20:20:14+02:00
[INFO] Final Memory: 8M/155M
[INFO] ------------------------------------------------------------------------
D:\SpringSTS\sts-tezgah\conquisitio>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building conquisitio 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ conquisitio ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 60 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ conquisitio ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\SpringSTS\sts-tezgah\conquisitio\target\classes
[WARNING] error reading C:\Users\Levent\.m2\repository\com\h2database\h2\1.4.190\h2-1.4.190.jar; invalid LOC header (bad signature)
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ conquisitio ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\SpringSTS\sts-tezgah\conquisitio\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ conquisitio ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\SpringSTS\sts-tezgah\conquisitio\target\test-classes
[WARNING] error reading C:\Users\Levent\.m2\repository\com\h2database\h2\1.4.190\h2-1.4.190.jar; invalid LOC header (bad signature)
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ conquisitio ---
[INFO] Surefire report directory: D:\SpringSTS\sts-tezgah\conquisitio\target\surefire-reports
[WARNING] error reading C:\Users\Levent\.m2\repository\com\h2database\h2\1.4.190\h2-1.4.190.jar; invalid LOC header (bad signature)

[WARNING] error reading C:\Users\Levent\.m2\repository\com\h2database\h2\1.4.190\h2-1.4.190.jar; invalid LOC header (bad signature)

这两个都暗示了h2database JAR,因为这些JAR已损坏,所以spring boot无法加载相关的类。

只需删除maven缓存中出现在mvn install命令输出中的相关依赖项。

删除下的所有内容;

C:\Users\Levent\.m2\repository\com\h2database\
Maven automatically downloads the related jar files and project is running ok with the new uncorrupted jar files;

D:\SpringSTS\sts-tezgah\conquisitio>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building conquisitio 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/com/h2database/h2/1.4.190/h2-1.4.190.pom
Downloaded: https://repo.maven.apache.org/maven2/com/h2database/h2/1.4.190/h2-1.4.190.pom (962 B at 991 B/s)
Downloading: https://repo.maven.apache.org/maven2/com/h2database/h2/1.4.190/h2-1.4.190.jar
Downloaded: https://repo.maven.apache.org/maven2/com/h2database/h2/1.4.190/h2-1.4.190.jar (1.7 MB at 1.5 MB/s)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ conquisitio ---
[INFO] Deleting D:\SpringSTS\sts-tezgah\conquisitio\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ conquisitio ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 60 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ conquisitio ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\SpringSTS\sts-tezgah\conquisitio\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ conquisitio ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\SpringSTS\sts-tezgah\conquisitio\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ conquisitio ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\SpringSTS\sts-tezgah\conquisitio\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ conquisitio ---
[INFO] Surefire report directory: D:\SpringSTS\sts-tezgah\conquisitio\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.levent.conquisitio.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec - in com.levent.conquisitio.AppTest

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ conquisitio ---
[INFO] Building jar: D:\SpringSTS\sts-tezgah\conquisitio\target\conquisitio-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.3.1.RELEASE:repackage (default) @ conquisitio ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ conquisitio ---
[INFO] Installing D:\SpringSTS\sts-tezgah\conquisitio\target\conquisitio-0.0.1-SNAPSHOT.jar to C:\Users\Levent\.m2\repository\com\levent\conquisitio\0.0.1-SNAPSHOT\conquisitio-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\SpringSTS\sts-tezgah\conquisitio\pom.xml to C:\Users\Levent\.m2\repository\com\levent\conquisitio\0.0.1-SNAPSHOT\conquisitio-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.823 s
[INFO] Finished at: 2017-10-07T20:21:42+02:00
[INFO] Final Memory: 30M/213M
[INFO] ------------------------------------------------------------------------
 类似资料:
  • 问题内容: 使用嵌入式h2数据源以及JUnit(可选),用于集成测试的Spring配置看起来如何? 我第一次尝试使用SingleConnectionDataSource基本上可以成功,但是在更复杂的测试中失败了,在该测试中您需要同时进行多个连接或暂停事务。我认为基于tcp的服务器模式下的 h2 可能也能正常工作,但这可能不是内存中临时嵌入式数据库最快的通信模式。 有哪些可能性及其优势/劣势?另外,

  • 由于以下配置,我希望在web浏览器中查看Spring启动的H2数据库的内容: 我在日志中搜索了JDBC URL: 这样我就可以按照以下方式填写连接表单: 你知道吗? 谢了!

  • 问题内容: 由于以下配置,我想在Web浏览器中查看Spring启动的H2数据库的内容: 我在日志中搜索了JDBC URL: 但是不幸的是,数据库仍然是空的,但是由于populateDB.sql脚本,它不应该是空的。 任何想法? 谢谢! 问题答案: 本文向大家介绍查看Spring启动的嵌入式H2数据库的内容相关面试题,主要包含被问及查看Spring启动的嵌入式H2数据库的内容时的应答技巧和注意事项,

  • 问题内容: 因此,我最近才开始学习有关数据库如何工作,如何使用SQL ect的知识。并决定开始在我的Java应用程序(特别是H2数据库)中实现嵌入式数据库,并且在我编写代码的计算机上似乎运行良好。 当我移到另一台计算机上继续进行编码时,我注意到,即使我移植了嵌入式数据库文件(h2-*。jar),我在第一台计算机上创建的所有准备好的表也不在第二台计算机上存在。我以某种方式先入为主,即通过数据库引擎生

  • 我对一个应用程序的JPA层进行了几个单元测试。这个JPA层由JPA实体和一个提供持久化实体所需的基本API的服务组成。单元TET直接使用javax.Persistence类来处理PersistenceManager。然后测试持久性API,我可以在日志中看到创建表和序列等的SQL语句。 persistence.xml文件的相关部分如下所示: 我已经下载了Windows安装程序H2 1.4.200,并

  • 所以我用了这个嵌入Kafka的例子,还有这个 我对这个示例做了一点更改,并用一些数据库(如h2db)更新了kafka侦听器。 现在在我的单元测试中,当我想检查数据在数据库中是否可用时,我得到NULL。另外,我不确定如何手动检查数据库,因为h2是一个内存基础数据库。 这是更新的部分:在接收器类中 在单元测试中: 但 dt 始终为空。此外,我也无法检查数据库,因为它在测试停止后停止。有人知道如何使它可