spring-data-cassandra 1.5.0.M1 BeanInstantiationException
spring-data-cassandra 1.5.0.M1 BeanInstantiationException
当运行 spring启动应用程序时,出现以下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:实例;
进入源代码时,发现了这个:
最初我忘记添加 CassandraConfig class (http://docs.spring.io/spring-data/cassandra/docs/1.5.0.M1/reference/html/#cassandra-connectors.javaconfig) 这不是 spring-boot 提供的示例的一部分。所以现在可以了。
当运行 spring启动应用程序时,出现以下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:实例;
进入源代码时,发现了这个:
最初我忘记添加 CassandraConfig class (http://docs.spring.io/spring-data/cassandra/docs/1.5.0.M1/reference/html/#cassandra-connectors.javaconfig) 这不是 spring-boot 提供的示例的一部分。所以现在可以了。