java.lang.annotation.AnnotationFormatError:EnableCassandraRepositories

时间:2016-10-19 18:47:59

标签: spring-boot cassandra

我正在使用cassandra的spring boot但是enableCassandraRepositories注释会抛出一些异常,请建议

package com.tarun.application;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;

@ComponentScan
@EnableAutoConfiguration
@EnableCassandraRepositories(basePackages = "com.tarun.application.dao")

public class Application {

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
} 
}

java.lang.annotation.AnnotationFormatError:默认无效:public abstract java.lang.Class org.springframework.data.cassandra.repository.config.EnableCassandraRepositories.repositoryBaseClass()     at java.lang.reflect.Method.getDefaultValue(Unknown Source)     at sun.reflect.annotation.AnnotationType。(Unknown Source)     at sun.reflect.annotation.AnnotationType.getInstance(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotation2(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)     at java.lang.Class.createAnnotationData(Unknown Source)     在java.lang.Class.annotationData(未知来源)     at java.lang.Class.getDeclaredAnnotations(Unknown Source)     在org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:360)     在org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:338)     在org.springframework.boot.BeanDefinitionLoader.isComponent(BeanDefinitionLoader.java:271)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:158)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)     在org.springframework.boot.SpringApplication.load(SpringApplication.java:615)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:314)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:957)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:946)     在com.tarun.application.Application.main(Application.java:14)

线程“main”中的异常java.lang.annotation.AnnotationFormatError:默认无效:public abstract java.lang.Class org.springframework.data.cassandra.repository.config.EnableCassandraRepositories.repositoryBaseClass()     at java.lang.reflect.Method.getDefaultValue(Unknown Source)     at sun.reflect.annotation.AnnotationType。(Unknown Source)     at sun.reflect.annotation.AnnotationType.getInstance(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotation2(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)     at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)     at java.lang.Class.createAnnotationData(Unknown Source)     在java.lang.Class.annotationData(未知来源)     at java.lang.Class.getDeclaredAnnotations(Unknown Source)     在org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:360)     在org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:338)     在org.springframework.boot.BeanDefinitionLoader.isComponent(BeanDefinitionLoader.java:271)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:158)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135)     在org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)     在org.springframework.boot.SpringApplication.load(SpringApplication.java:615)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:314)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:957)     在org.springframework.boot.SpringApplication.run(SpringApplication.java:946)     在com.tarun.application.Application.main(Application.java:14)

1 个答案:

答案 0 :(得分:0)

当默认情况下指定的类不在类路径上时,会出现此问题。检查您是否包含spring-data-commons