【问题标题】:Univocity Parsers, "Cannot resolve method writeValue(int)"?Univocity 解析器,“无法解析方法 writeValue(int)”?
【发布时间】:2016-01-13 12:43:16
【问题描述】:

Univocity Parsers, "Cannot resolve method writeValue(int)" 出现以下代码,在 IntelliJ 中打开,任何帮助将不胜感激:

public void write(){

        // Writing to an in-memory byte array. This will be printed out to the standard output so you can easily see the result.
        ByteArrayOutputStream csvResult = new ByteArrayOutputStream();

        // CsvWriter (and all other file writers) work with an instance of java.io.Writer
        Writer outputWriter = new OutputStreamWriter(csvResult);

        TsvWriter writer = new TsvWriter(outputWriter, new TsvWriterSettings());

        writer.writeHeaders("A", "B", "C", "D", "E");

        //writes a value to the first column
        writer.writeValue(10);

        //writes a value to the second column
        writer.writeValue(20);

        //writes a value to the fourth column (index 3 represents the 4th column - the one with header "D")
        writer.writeValue(3, 40);

        //overrides the value in the first column. "A" indicates the header name.
        writer.writeValue("A", 100.0);

        //flushes all values to the output, creating a row.
        writer.writeValuesToRow();
    }

【问题讨论】:

    标签: parsing csv writing


    【解决方案1】:

    您似乎从使用 2.0.0-SNAPSHOT 版本构建的示例中获得了此示例。更新您的 pom.xml 以使用

    <dependency>
        <groupId>com.univocity</groupId>
        <artifactId>univocity-parsers</artifactId>
        <version>2.0.0-SNAPSHOT</version>
    </dependency>
    

    您可能还需要将以下内容添加到您的 pom.xml 中,以使 maven 能够获取快照构建:

    <repositories>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>
    

    如果你不使用maven你可以直接去下面的url:https://oss.sonatype.org/content/repositories/snapshots/com/univocity/univocity-parsers/2.0.0-SNAPSHOT/

    最后,此示例取自快照版本,您使用的方法已重命名为 addValue。检查示例here

    【讨论】:

    • 嗯,将 univocity-parsers-2.0.0-20151116.050805-20.jar 从该链接添加到项目库中,IntelliJ 仍然无法解析此语句中的 writeValue writer.writeValue(10);跨度>
    • 您有一张旧快照。滚动到页面底部以获取最新消息:oss.sonatype.org/content/repositories/snapshots/com/univocity/…
    • 嗯,这个链接https://oss.sonatype.org/content/repositories/snapshots/com/univocity/univocity-parsers/2.0.0-SNAPSHOT/univocity-parsers-2.0.0-20160115.024244-24.jar会生成404,有有效链接吗?,谢谢。
    • 那是因为文件夹包含快照!随着时间的推移,它们会被替换。只需滚动到页面底部。检查最新日期并获取最新版本。
    • 哈,改名为“addValue”。检查示例here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 2016-05-08
    • 2021-03-03
    • 2018-01-15
    • 2015-08-30
    • 2016-05-26
    相关资源
    最近更新 更多