简体   繁体   English

使用Spring Boot与Cassandra的Maven编译错误

[英]Maven Compilation Error using Spring Boot with Cassandra

I am setting up a Spring Boot application with Cassandra repository. 我正在使用Cassandra存储库设置一个Spring Boot应用程序。 Maven has gone rogue though, because the application stopped compiling. 由于应用程序停止了编译 ,因此Maven变得无赖 Spring Data Cassandra is not getting handled properly. Spring Data Cassandra处理不正确。 Everything in "org.springframework.cassandra.core.mapping" does not exist locally. “ org.springframework.cassandra.core.mapping” 中的所有内容都不在本地存在 And it looks like I have other packages "...cassandra.core" that are OK. 看起来我还有其他可以的包“ ... cassandra.core”。

Cassandra bean mapping classes like @Table, @Column, etc. fail with "cannot find symbol" in Maven compilation. 在Maven编译中,诸如@ Table,@ Column等的Cassandra bean映射类会失败,并显示“找不到符号”。 I tried cleaning, and even tried deleting my ./.m2/repository, but it cannot compile. 我尝试清理,甚至尝试删除./.m2/存储库,但无法编译。 I expect some version mismatch must be happening, or it could be time to start using Gradle. 我预计一定会发生版本不匹配的情况,否则可能是时候开始使用Gradle了。

I have run "jar tvf spring-data-cassandra-1.5.9.RELEASE.jar | grep 'mapping'" and the mapping.* classes are all present. 我已经运行了“ jar tvf spring-data-cassandra-1.5.9.RELEASE.jar | grep'mapping'”,并且mapping。*类都存在。 Yet, "mvn clean compile" results in multiple homogeneous errors of: 但是,“ mvn clean compile”会导致多个同类错误:

[ERROR] /media/kevvurs/ExtraDrive1/winshare/workspace/FPSJobsRedesign/FPSDistributionFilter/src/main/java/com/shc/scinventory/dfilter/data/DcUnitInfoBean.java:[4,55] package org.springframework.data.cassandra.core.mapping does not exist [错误] /media/kevvurs/ExtraDrive1/winshare/workspace/FPSJobsRedesign/FPSDistributionFilter/src/main/java/com/shc/scinventory/dfilter/data/DcUnitInfoBean.java:[4,55]包org.springframework.data。 cassandra.core.mapping不存在

pom.xml pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample.app</groupId>
<artifactId>Filter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Filter</name>
<description>Command-line tool</description>
<properties>
    <maven.antrun.plugin.version>1.7</maven.antrun.plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jdk.version>1.8</jdk.version>
</properties>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.beust</groupId>
        <artifactId>jcommander</artifactId>
        <version>1.72</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.13</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-testng</artifactId>
                    <version>2.17</version>
                </dependency>
            </dependencies>
            <configuration>
                <groups>dev</groups>
            </configuration>
            <executions>
                <execution>
                    <phase>test</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Solved 解决了
I was integrating a class that uses a different, non-Boot, configuration of Spring. 我正在集成一个类,该类使用不同的,非引导的Spring配置。 I had tried importing @Table and other Spring Data annotations from: org.springframework.data.cassandra. 我曾尝试从org.springframework.data.cassandra导入@Table和其他Spring Data批注。 core .mapping.Table when it is provided in org.springframework.data.cassandra.mapping.Table for when using spring-boot-starter-data-cassandra. org.springframework.data.cassandra.mapping.Table中提供的核心 .mapping.Table用于使用spring-boot-starter-data-cassandra时。

Conclusion 结论
I sometimes depend too much on Intellij and tools for refactoring and auto-completing things. 有时我过于依赖Intellij和工具来进行重构和自动完成。 The problem would have been obvious if I had paid more attention. 如果我多加注意,这个问题就很明显了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM