我的新项目有问题,我收到这个我无法解决的错误,我在github上加载项目我认为这是一个配置问题。
https://github.com/DeAngelisLuca/Traccialo
application.properties
spring.datasource.url= jdbc:postgresql://localhost/traccialo
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.hibernate.hbm2ddl.auto=update
spring.jpa.hibernate.show_sql=true
hibernate.temp.use_jdbc_metadata_defaults false
stackTrace的一部分
2018-04-15 19:54:27.672 INFO 9696 --- [ main] i.d.Traccialo.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on PC-Luca with PID 9696 (C:\Users\Luca\eclipse-workspace-professional\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Traccialo\WEB-INF\classes started by Luca in C:\Users\Luca\Downloads\eclipse-jee-oxygen-3-win32-x86_64\eclipse)
2018-04-15 19:54:27.675 INFO 9696 --- [ main] i.d.Traccialo.ServletInitializer : No active profile set, falling back to default profiles: default
2018-04-15 19:54:27.752 INFO 9696 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@25b78608: startup date [Sun Apr 15 19:54:27 CEST 2018]; root of context hierarchy
2018-04-15 19:54:28.569 INFO 9696 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
2018-04-15 19:54:29.273 INFO 9696 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$dc6cce97] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-15 19:54:29.358 INFO 9696 --- [ main] o.a.c.c.C.[.[localhost].[/Traccialo] : Initializing Spring embedded WebApplicationContext
2018-04-15 19:54:29.358 INFO 9696 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1606 ms
2018-04-15 19:54:29.768 INFO 9696 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-15 19:54:29.769 INFO 9696 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2018-04-15 19:54:29.769 INFO 9696 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-15 19:54:29.770 INFO 9696 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-15 19:54:29.770 INFO 9696 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-15 19:54:29.770 INFO 9696 --- [ main] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-04-15 19:54:29.770 INFO 9696 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-04-15 19:54:30.022 INFO 9696 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-04-15 19:54:30.153 INFO 9696 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-04-15 19:54:30.229 INFO 9696 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-04-15 19:54:30.264 INFO 9696 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-04-15 19:54:30.465 INFO 9696 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.16.Final}
2018-04-15 19:54:30.469 INFO 9696 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-04-15 19:54:30.562 INFO 9696 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-04-15 19:54:30.836 INFO 9696 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL95Dialect
2018-04-15 19:54:30.961 INFO 9696 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_161]
答案 0 :(得分:0)
这个例外只发生在jdbc驱动程序4不匹配时(我想是这样,我之前已经讨论过了),正如你所知,hibernate是一个ORM工具,所以要创建一个连接,它需要来自的一些元数据信息。数据库中。
您可以将此行添加到application.properties
hibernate.temp.use_jdbc_metadata_defaults = false
如果您有hibernate.cfg.xml
作为配置文件,那么您可以将此行添加到配置文件
hibernate.cfg.xml文件添加以下属性
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
注意: - 如果您发现
application.properties
键值对必须与=
(赋值运算符)分开。请将此添加到您的代码中
希望这会帮助你。谢谢:))