Spring Boot - 上下文初始化期间遇到的异常。如何知道错误的原因?

时间:2018-03-18 01:14:27

标签: java spring spring-boot

如果没有堆栈跟踪,我怎么知道问题是什么?我可以启用一些选项吗? 我刚用spring springizer创建了一个小项目,这就是我得到的

更新了日志(带有调试标志)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

2018-03-18 02:40:52.246  INFO 16664 --- [  restartedMain] c.o.b.BigDataProjectApplication          : Starting BigDataProjectApplication on oscar-Inspiron-5735 with PID 16664 (/home/oscar/IdeaProjects/big-data-project/out/production/classes started by oscar in /home/oscar/IdeaProjects/big-data-project)
2018-03-18 02:40:52.253  INFO 16664 --- [  restartedMain] c.o.b.BigDataProjectApplication          : No active profile set, falling back to default profiles: default
2018-03-18 02:40:52.254 DEBUG 16664 --- [  restartedMain] o.s.boot.SpringApplication               : Loading source class com.owozniak.bigdataproject.BigDataProjectApplication
2018-03-18 02:40:52.476 DEBUG 16664 --- [  restartedMain] o.s.b.c.c.ConfigFileApplicationListener  : Loaded config file 'file:/home/oscar/IdeaProjects/big-data-project/out/production/resources/application.properties' (classpath:/application.properties)
2018-03-18 02:40:52.512  INFO 16664 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@c156816: startup date [Sun Mar 18 02:40:52 CET 2018]; root of context hierarchy
2018-03-18 02:40:52.516 DEBUG 16664 --- [  restartedMain] ConfigServletWebServerApplicationContext : Bean factory for org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@c156816: org.springframework.beans.factory.support.DefaultListableBeanFactory@5f820b6d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,bigDataProjectApplication]; root of factory hierarchy
2018-03-18 02:40:55.008 DEBUG 16664 --- [  restartedMain] o.s.b.a.AutoConfigurationPackages        : @EnableAutoConfiguration was declared on a class in the package 'com.owozniak.bigdataproject'. Automatic @Repository and @Entity scanning is enabled.
2018-03-18 02:40:55.882  INFO 16664 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$54765f50] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-18 02:40:55.959 DEBUG 16664 --- [  restartedMain] ConfigServletWebServerApplicationContext : Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@1214c019]
2018-03-18 02:40:55.959 DEBUG 16664 --- [  restartedMain] ConfigServletWebServerApplicationContext : Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@41ee5a59]
2018-03-18 02:40:56.386 DEBUG 16664 --- [  restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: /home/oscar/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.0.0.RELEASE/771da2071ff14a47f108642a641c204ae4ef7b15/spring-boot-2.0.0.RELEASE.jar
2018-03-18 02:40:56.387 DEBUG 16664 --- [  restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: /home/oscar/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.0.0.RELEASE/771da2071ff14a47f108642a641c204ae4ef7b15/spring-boot-2.0.0.RELEASE.jar
2018-03-18 02:40:56.388 DEBUG 16664 --- [  restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2018-03-18 02:40:56.551  INFO 16664 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-03-18 02:40:56.604  INFO 16664 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-03-18 02:40:56.605  INFO 16664 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2018-03-18 02:40:56.616  INFO 16664 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-03-18 02:40:56.838  INFO 16664 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-03-18 02:40:56.838  INFO 16664 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4361 ms
2018-03-18 02:40:57.959 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Added existing Servlet initializer bean 'dispatcherServletRegistration'; order=2147483647, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class]
2018-03-18 02:40:57.959 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Added existing Filter initializer bean 'webMvcMetricsFilter'; order=2147483647, resource=class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]
2018-03-18 02:40:57.961 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Added existing ServletContextInitializer initializer bean 'servletEndpointRegistrar'; order=2147483647, resource=class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]
2018-03-18 02:40:58.051 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'characterEncodingFilter'; order=-2147483648, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.class]
2018-03-18 02:40:58.051 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'hiddenHttpMethodFilter'; order=-10000, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]
2018-03-18 02:40:58.052 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'httpPutFormContentFilter'; order=-9900, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]
2018-03-18 02:40:58.052 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'requestContextFilter'; order=-105, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]
2018-03-18 02:40:58.052 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'httpTraceFilter'; order=2147483637, resource=class path resource [org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceAutoConfiguration$ServletTraceFilterConfiguration.class]
2018-03-18 02:40:58.065  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-03-18 02:40:58.070  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-18 02:40:58.071  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-18 02:40:58.072  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-18 02:40:58.072  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-18 02:40:58.072  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
2018-03-18 02:40:58.073  INFO 16664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-03-18 02:40:58.090 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.f.OrderedRequestContextFilter  : Initializing filter 'requestContextFilter'
2018-03-18 02:40:58.092 DEBUG 16664 --- [ost-startStop-1] o.s.b.w.s.f.OrderedRequestContextFilter  : Filter 'requestContextFilter' configured successfully
2018-03-18 02:40:58.095 DEBUG 16664 --- [ost-startStop-1] o.s.b.a.m.w.servlet.WebMvcMetricsFilter  : Initializing filter 'webMvcMetricsFilter'
2018-03-18 02:40:58.096 DEBUG 16664 --- [ost-startStop-1] o.s.b.a.m.w.servlet.WebMvcMetricsFilter  : Filter 'webMvcMetricsFilter' configured successfully
2018-03-18 02:40:58.097 DEBUG 16664 --- [ost-startStop-1] .b.w.s.f.OrderedHttpPutFormContentFilter : Initializing filter 'httpPutFormContentFilter'
2018-03-18 02:40:58.097 DEBUG 16664 --- [ost-startStop-1] .b.w.s.f.OrderedHttpPutFormContentFilter : Filter 'httpPutFormContentFilter' configured successfully
2018-03-18 02:40:58.097 DEBUG 16664 --- [ost-startStop-1] .s.b.w.s.f.OrderedHiddenHttpMethodFilter : Initializing filter 'hiddenHttpMethodFilter'
2018-03-18 02:40:58.098 DEBUG 16664 --- [ost-startStop-1] .s.b.w.s.f.OrderedHiddenHttpMethodFilter : Filter 'hiddenHttpMethodFilter' configured successfully
2018-03-18 02:40:58.098 DEBUG 16664 --- [ost-startStop-1] s.b.w.s.f.OrderedCharacterEncodingFilter : Initializing filter 'characterEncodingFilter'
2018-03-18 02:40:58.099 DEBUG 16664 --- [ost-startStop-1] s.b.w.s.f.OrderedCharacterEncodingFilter : Filter 'characterEncodingFilter' configured successfully
2018-03-18 02:40:58.099 DEBUG 16664 --- [ost-startStop-1] o.s.b.a.w.trace.servlet.HttpTraceFilter  : Initializing filter 'httpTraceFilter'
2018-03-18 02:40:58.099 DEBUG 16664 --- [ost-startStop-1] o.s.b.a.w.trace.servlet.HttpTraceFilter  : Filter 'httpTraceFilter' configured successfully
2018-03-18 02:40:58.265  INFO 16664 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-03-18 02:40:58.836  INFO 16664 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-03-18 02:40:58.917  INFO 16664 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-03-18 02:40:58.937  INFO 16664 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2018-03-18 02:40:59.046  INFO 16664 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.14.Final}
2018-03-18 02:40:59.048  INFO 16664 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-03-18 02:40:59.100  INFO 16664 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-03-18 02:40:59.251  INFO 16664 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-03-18 02:41:00.092  WARN 16664 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2018-03-18 02:41:00.094  INFO 16664 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2018-03-18 02:41:00.106  INFO 16664 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2018-03-18 02:41:00.111  INFO 16664 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-03-18 02:41:00.135 DEBUG 16664 --- [  restartedMain] o.s.boot.devtools.restart.Restarter      : Creating new Restarter for thread Thread[main,5,main]
2018-03-18 02:41:00.135 DEBUG 16664 --- [  restartedMain] o.s.boot.devtools.restart.Restarter      : Immediately restarting application
2018-03-18 02:41:00.136 DEBUG 16664 --- [  restartedMain] o.s.boot.devtools.restart.Restarter      : Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@20f4e97e
2018-03-18 02:41:00.136 DEBUG 16664 --- [  restartedMain] o.s.boot.devtools.restart.Restarter      : Starting application com.owozniak.bigdataproject.BigDataProjectApplication with URLs [file:/home/oscar/IdeaProjects/big-data-project/out/production/classes/, file:/home/oscar/IdeaProjects/big-data-project/out/production/resources/]

Process finished with exit code 0

当我删除所有注释弹簧数据jpa(@ Entity,@ OneToMay等)时,服务器正在工作

3 个答案:

答案 0 :(得分:0)

如果您使用的是MySQL数据库, 您可能遇到以下问题:https://hibernate.atlassian.net/browse/HHH-10490

更改以下行:

properties.setProperty("hibernate.default_schema", defaultSchema);

为:

properties.setProperty("hibernate.default_catalog", defaultSchema);

请注意,您可能还希望将属性名称从“defaultSchema”更改为“defaultCatalog”。

答案 1 :(得分:0)

我通过将gradle改为maven来“解决”它

答案 2 :(得分:-1)

这可能与您的问题有关:spring boot discussion

spring boot github issue

您也可以最后调试SpringApplication#reportFailure(在catch(可抛出)之后),它具有任何错误的常规日志记录:

logger.error("Application run failed", ex)

在我的情况下,我使记录器无法进行commons-logging,因此无法进行记录。