My 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.cassandra</groupId>
<artifactId>simple-client</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<dependencies>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<mainClass>com.example.cassandra.Client</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
My java file
package com.example.cassandra;
import com.datastax.driver.core.Cluster;
public class Client
{
// private Cluster cluster;
public static void main(String a[])
{
System.out.println("I am in");
}
}
I compiled it using
mvn -e compile
it says
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:2.0.2:compile (default-compile) on project simple-client:
Compilation failure
[ERROR] /cassandra/src/main/java/com/example/cassandra/Client.java:[3,31]
error: package com.datastax.driver.core does not exist
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal org.apache.maven.plugins:maven-compiler-
plugin:2.0.2:compile (default-compile) on project simple-client:
Compilation failure
/cassandra/src/main/java/com/example/cassandra/Client.java:[3,31]
error: package com.datastax.driver.core does not exist
I understand that dependency jar
is improperly added
since it complains package doesnot exist. Where do i add that dependency so that my code will compile and tun successfully?
For more info I am referring this site to run this example
Structure of the project
Cassandra
pom.xml
src
main
java
com
example
cassandra
Client.java
I am running these commands from Cassandra directory that is where pom.xml presents