Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

qianjizheng avatar image
qianjizheng asked ·

java-driver-mapper-processor cannot find symbol for MapperBuilder

I tried to use the mapper based on https://docs.datastax.com/en/developer/java-driver/4.8/manual/mapper/config/

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.8.1</version>
   <configuration>
      <source>1.8</source> <!-- (or higher) -->
      <target>1.8</target> <!-- (or higher) -->
      <annotationProcessorPaths>
         <path>
            <groupId>com.datastax.oss</groupId>
            <artifactId>java-driver-mapper-processor</artifactId>
            <version>4.8.0</version>
         </path>
      </annotationProcessorPaths>
   </configuration>
</plugin>

When I tried to build it using mvn install, it complained that it cannot find the related MapperBuilder. Annotation processing is not working for me.

I also tried adding the dependency

<dependency>
   <groupId>com.datastax.oss</groupId>
   <artifactId>java-driver-mapper-processor</artifactId>
   <version>${datastax.driver.version}</version>
   <scope>provided</scope>
</dependency>

I can build it in Intellij with "Annotation Processing" enabled in the project but not able to build it using command line. The maven version used in Intellij and command line are the same (3.6.1)

java driver
1 comment
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Could you please edit your original question (please don't post it as an "answer") with the full contents of your pom.xml? Cheers!

0 Likes 0 · ·

1 Answer

Cedrick Lunven avatar image
Cedrick Lunven answered ·

Hi,

Your configuration seems quite legit to me.

Here is `pom.xml` that compile with Maven as expected.


Checking discrepancies:

https://github.com/clun/spring-petclinic-reactive/blob/master/pom.xml


  1. bump to latest version `4.9.0`
  2. I did not used the `provided` keyword in definition of the annotation processor


<cassandra-java-driver.version>4.9.0</cassandra-java-driver.version> <cassandra-native-protocol.version>1.4.11</cassandra-native-protocol.version>


Then

<dependency> 
 <groupId>com.datastax.oss</groupId>
 <artifactId>java-driver-core</artifactId>
 <version>${cassandra-java-driver.version}</version>
 <exclusions>
   <exclusion>
     <groupId>org.apache.tinkerpop</groupId>
     <artifactId>*</artifactId> 
    </exclusion>
 </exclusions> 
</dependency> 

<dependency>
 <groupId>com.datastax.oss</groupId>
 <artifactId>java-driver-query-builder</artifactId>
 <version>${cassandra-java-driver.version}</version>
</dependency>

<dependency>
 <groupId>com.datastax.oss</groupId>
 <artifactId>java-driver-mapper-runtime</artifactId>
 <version>${cassandra-java-driver.version}</version>
</dependency>

<dependency>
 <groupId>com.datastax.oss</groupId>
 <artifactId>native-protocol</artifactId>
 <version>${cassandra-native-protocol.version}</version>
</dependency>
</dependencies> 

<build>
 <plugins>
   <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <release>${java.version}</release> 
     <source>${java.version}</source> 
     <target>${java.version}</target> 
     <showWarnings>false</showWarnings> 
     <annotationProcessorPaths> 
      <path> 
        <groupId>com.datastax.oss</groupId> 
        <artifactId>java-driver-mapper-processor</artifactId> 
        <version>${cassandra-java-driver.version}</version> 
       </path> 
      </annotationProcessorPaths> 
     </configuration>
    </plugin>
   </plugins>
</build>


Tell us if it helped

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1. My company does not have 4.9 in the repository yet.

2. I did not use the `provided` keyword in definition of the annotation processor in the build plugin neither. If I did not use annotation processing in the build and put it in the dependency, it will build using Intellij with annotation processing enabled. However, it won't build in command line.

3. After taking the pom you pasted, I still cannot build.

0 Likes 0 · ·