将springboot应用程序与部署在openshift上的cassandra集成

时间:2019-02-26 06:24:27

标签: java spring spring-boot spring-mvc cassandra

我已经在openshift中部署了cassandra 3.11服务(OpenShift Web控制台)     通过端口转发,我将通过本地连接到cassandra服务     终奌站。     oc port-forward cassandra-0 9042:9042     cqlsh -u cassandra -p cassandra 我想通过我的springboot应用程序访问cassandra服务。 为此,我正在使用下面的属性文件。

spring.data.cassandra.contact-points=cassandra-0.cassandra-1:9042,cassandra-1.cassandra-1:9042,cassandra-2.cassandra-1:9042
#spring.data.cassandra.port=9042
spring.data.cassandra.username=cassandra
spring.data.cassandra.password=cassandra
spring.data.cassandra.cluster-name=cassandra

When I am trying to run springboot application through above property file I am getting below error 

org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework /boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate forg.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrad: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate /autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate /autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org. springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cassandraTemplate' defined in class path resource [o rg/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'cassandraTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [org/springframework /boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]: Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host cassandra.b360—non—prod.svc/10.128.16.156:9042: Host cassandra.b360— non—prod.svc/10.128.16.156:9042 requires authentication, but no authenticator found in Cluster configuration 2019-02-12 00:59:50.026 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2019-02-12 00:59:50.141 WARN 1 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [cluster1— connection—reaper-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: 

1 个答案:

答案 0 :(得分:0)

尝试localhost:9042

oc port-forward可以将请求从本地转发到远程Pod。因此,访问localhost:9042将转发到cassandra-0:9042