我正在尝试在我的 Spring 应用程序中使用 PGJDBC-NG 驱动程序进行 Postgress JDBC 连接。
@Bean
@Qualifier("dataSource1")
public DataSource getDataSource1() {
PGDataSource dataSource = new PGDataSource();
// anmol :Removed VCAP_SERVICES and Changes has done according to docker
try {
dataSource.setUser(env.getRequiredProperty(PROPERTY_BLUEMIX_DEMO_NAME_POSTGRESQL_DATABASE_USERNAME).trim());
dataSource.setPassword(env.getRequiredProperty(PROPERTY_BLUEMIX_DEMO_NAME_POSTGRESQL_DATABASE_PASSWORD).trim());
dataSource.setDataSourceName("com.impossibl.postgres.jdbc.PGDataSource");
dataSource.setDatabaseUrl("jdbc:pgsql://localhost:5432/test");
dataSource.setRegistrySharing(true);
dataSource.setApplicationName("com.impossibl.postgres.jdbc.PGDriver");
dataSource.setSslMode("verify-full");
dataSource.setSslCertificateFile("postgresql.crt");
dataSource.setSslCaCertificateFile("root.crt");
dataSource.setSslKeyFile("postgresql.pk8");
dataSource.setSslKeyPassword("None");
dataSource.setSslKeyPasswordCallback("com.impossibl.postgres.protocol.ssl.ConsolePasswordCallbackHandler");
dataSource.setSslHomeDir(".postgresql");
}catch (Exception e) {
e.printStackTrace();
}
return dataSource;
}
但是在运行时给出错误...
`[err] org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.IncompatibleClassChangeError: Class io.netty.channel.DefaultChannelHandlerContext does not implement the requested interface io.netty.channel.ChannelOutboundInvoker
[err] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:978) [err] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [err] at org. springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [err] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [err] at javax.servlet.http.HttpServlet。 service(HttpServlet.java:707) [err] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [err] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [err] 在 com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1287) [err] 在 [internal classes] [err] 在 hcl.common.filter.FilterToGetTimeOut.doFilterInternal(FilterToGetTimeOut.java:50) [err] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [err] at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:207) [err ] 在 [internal classes] [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) [err] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke( FilterSecurityInterceptor.java:127) [err] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter( FilterChainProxy.java:331) [err] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [err] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) [错误] 在 org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [错误] 在 org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [错误] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [err] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain。doFilter(FilterChainProxy.java:331) [err] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter( FilterChainProxy.java:331) [err] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy. java:331) [err] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy. java:331) [err] 在 org.springframework.security.web.csrf.CsrfFilter。doFilterInternal(CsrfFilter.java:124) [err] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [err] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy. java:331) [err] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66) [err] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [err] 在 org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [err] 在 org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [err ] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [err] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [err] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [err] at org. springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [err] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) [err] at org.springframework.security。 web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [err] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [err] at org.springframework.web.filter.DelegatingFilterProxy.doFilter( DelegatingFilterProxy.java:262) [err] 在 com.ibm.ws.webcontainer.filter.FilterInstanceWrapper。doFilter(FilterInstanceWrapper.java:207) [err] at [internal classes] [err] at org.springframework.web.multipart.support.MultipartFilter.doFilterInternal(MultipartFilter.java:122) [err] at org.springframework.web。 filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [err] at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:207) [err] at [internal classes] [err] at java。 util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [err] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [err] at java.lang.Thread.run(Thread. java:748) [err] 引起:java.lang.IncompatibleClassChangeError: Class io.netty.channel.DefaultChannelHandlerContext 没有在 com 实现请求的接口 io.netty.channel.ChannelOutboundInvoker [err]。impossibl.postgres.protocol.v30.ProtocolChannel.flush(ProtocolChannel.java:99) [err] 在 com.impossibl.postgres.protocol.v30.SSLQueryRequest.execute(SSLQueryRequest.java:104) [err] 在 com.impossibl。 postgres.protocol.v30.MessageDispatchHandler.write(MessageDispatchHandler.java:106) [err] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) [err] at io.netty.channel.AbstractChannelHandlerContext.access$2000 (AbstractChannelHandlerContext.java:32) [错误] 在 io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:939) [错误] 在 io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:991 ) [错误] 在 io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:924) [err] 在 io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370) [err] 在 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [err ] 在 io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [err] ... 1 更多`