运行spring boot应用程序时,获取以下BeanInstantiationException:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sampleCassandraApplication':
Unsatisfied dependency expressed through field 'repository':
Error creating bean with name 'customerRepository':
Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'cassandraTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]:
Unsatisfied dependency expressed through method 'cassandraTemplate' parameter 0: Error creating bean with name 'session' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]:
Unsatisfied dependency expressed through method 'session' parameter 0:
Error creating bean with name 'cassandraConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]:
Unsatisfied dependency expressed through method 'cassandraConverter' parameter 0:
Error creating bean with name 'cassandraMapping' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.data.cassandra.mapping.CassandraMappingContext]:
Factory method 'cassandraMapping' threw exception;
nested exception is java.lang.NoSuchFieldError: INSTANCE; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cassandraMapping' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.data.cassandra.mapping.CassandraMappingContext]:
Factory method 'cassandraMapping' threw exception; 嵌套异常为java.lang.NoSuchFieldError: INSTANCE;
当进入源代码时,发现了以下内容:

发布于 2016-08-29 14:51:47
最初,我忘记添加CassandraConfig类(http://docs.spring.io/spring-data/cassandra/docs/1.5.0.M1/reference/html/#cassandra-connectors.javaconfig),它不是spring-boot提供的示例的一部分。所以现在它起作用了。
https://stackoverflow.com/questions/39116222
复制相似问题