NoClassDefFoundError: com.opencsv.CSVWriter

后端 未结 2 682
不知归路
不知归路 2021-01-25 04:37

I am try to use opencsv libray to get encrypted format data. But while writing on CSV writer I am getting \"NoClassDefFoundError\". I have seen many post related with same error

2条回答
  •  滥情空心
    2021-01-25 04:40

    I have been struggling with getting OpenCSV set up with Maven and eclipse for a while due to exactly the same error. Ultimately I abandoned OpenCSV and used CSVParser instead, which is available from the Apache Commons and works much more readily.

    Update your POM with the dependency listed here, and the following will work out-of-the-box:

    import org.apache.commons.csv.CSVFormat;
    import org.apache.commons.csv.CSVParser;
    import org.apache.commons.csv.CSVRecord;
    
    import java.io.FileReader;
    import java.io.Reader;
    
    public class importFile {
        public static void main(String[] args) {
            Reader in = new FileReader( csvFileInput );
            CSVParser parser = new CSVParser( in, CSVFormat.DEFAULT );
            List list = parser.getRecords();
    
            for( CSVRecord row : list )
                for( String entry : row )
                    System.out.println( entry );
        }
    }
    

提交回复
热议问题