【问题标题】:spring-data-cassandra-2.0.0.RELEASE + spring-boot-starter-web-1.5.7.RELEASE causes java.lang.ClassNotFoundExceptionspring-data-cassandra-2.0.0.RELEASE + spring-boot-starter-web-1.5.7.RELEASE 导致 java.lang.ClassNotFoundException
【发布时间】:2018-03-28 08:55:58
【问题描述】:

我使用最新版本的 spring-data-cassandra 2.0.0.RELEASE 和最新版本的 spring-boot-starter-web - 1.5.7.RELEASE

  <dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-cassandra</artifactId>
        <version>2.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.7.RELEASE</version>
    </dependency>
</dependencies>

我可以毫无问题地构建项目,但是应用程序没有启动并出现以下异常:

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration.cassandraMapping
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at Application.main(Application.java:8) [classes/:na]

根本原因:

Caused by: java.lang.ClassNotFoundException: org.springframework.data.cassandra.mapping.CassandraMappingContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_144]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_144]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_144]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_144]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:255) ~[spring-core-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.addDeducedBeanTypeForBeanMethod(OnBeanCondition.java:356) ~[spring-boot-autoconfigure-1.5.7.RELEASE.jar:1.5.7.RELEASE]
... 21 common frames omitted

看起来问题出在 spring-boot-autoconfigure-1.5.7.RELEASE 中,如果我将 spring-boot-starter-web 更新为 2.0.0.M5:

<repositories>
    <repository>
        <id>spring-libs-snapshot</id>
        <url>https://repo.spring.io/libs-snapshot</url>
    </repository>
</repositories>

 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.0.0.M5</version>
 </dependency>

然后应用程序启动,没有任何错误。

有什么方法可以使用最新版本的 spring-data-cassandra 和 spring-boot-starter-web 或者我应该等待 spring-boot-starter-web:2.0.0 的 GA 吗?

提前谢谢你!

【问题讨论】:

    标签: spring-data-cassandra spring-boot-starter


    【解决方案1】:

    Spring Data Cassandra 的最新版本是 2.0.0,它与 Spring Boot 1.x 不兼容。您需要将依赖项升级到 Spring Boot 2.0 M5。

    【讨论】:

      【解决方案2】:

      嗨,我遇到了同样的问题,所以我做了什么, 首先,我在 cassandra 中连接多个键空间并使用具有 春季启动器 2.0.0.RELEASE 我删除了 spring data cassandra 的版本声明,但是它的托管版本是 2.0.5.RELEASE 所以你可以检查一下。 第二,当 org.springframework.data.cassandra.config.java.AbstractCassandraConfiguration 出现错误 在 2.0.0.RELEASE 之前和之前被导入,它被移动到 org.springframework.data.cassandra.config.AbstractCassandraConfiguration 所以请检查一下

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-03
        • 2020-06-02
        • 1970-01-01
        • 1970-01-01
        • 2018-12-31
        • 1970-01-01
        • 2018-09-26
        • 1970-01-01
        相关资源
        最近更新 更多