java - Maven cannot find opencsv csv parser -


i've come across 1 problem maven , opencsv

i trying use csvparser followed:

import java.io.ioexception; import au.com.bytecode.opencsv.csvparser; import org.apache.hadoop.io.*; import org.apache.hadoop.mapreduce.mapper;  public class flightsbycarriermapper extends                 mapper<longwritable, text, text, intwritable> {     @override     protected void map(longwritable key, text value, context context)             throws ioexception, interruptedexception {          if (key.get() > 0) {             string[] lines = new         csvparser().parseline(value.tostring());             context.write(new text(lines[8]), new intwritable(1));         }     } } 

i've added opencsv dependency , can use csvreader without problem. csvparser though cannot resolved , throws , error whenever try compile code.

maven throws following error.

[error] failed execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project flightsbycarrier: compilation failure: compilation failure: [error] /root/workspace/flightsbycarrier/src/main/java/com/root/hadoop/flightsbycarrier/flightsbycarriermapper.java:[6,30] error: cannot find symbol [error] package au.com.bytecode.opencsv [error] /root/workspace/flightsbycarrier/src/main/java/com/root/hadoop/flightsbycarrier/flightsbycarriermapper.java:[18,2] error: cannot find symbol 

the dependency looks right now:

<dependency>     <groupid>net.sf.opencsv</groupid>     <artifactid>opencsv</artifactid>     <version>1.8</version> </dependency> 

it seems class csvparser not exist in opencsv 1.8. class introduced in opencsv 2.1.

as such, need update dependency version 2.1 @ least.

<dependency>     <groupid>net.sf.opencsv</groupid>     <artifactid>opencsv</artifactid>     <version>2.1</version> </dependency> 

note starting 3.x branch, artifact relocated com.opencsv:opencsv coordinate. better use latest version of library:

<dependency>     <groupid>com.opencsv</groupid>     <artifactid>opencsv</artifactid>     <version>3.7</version> </dependency> 

you need update imports import com.opencsv.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -