小编Adr*_*rdt的帖子

依赖缺失?java.lang.NoSuchMethodError

我有一定的编程经验,但是对Maven来说还很陌生。在我的最新项目中,我正在使用Apache Commons API(配置,cli等)。它可以编译,但是在运行时抛出NoSuchMethod-exception。

我的依赖关系如下所示:

    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.3</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-configuration2</artifactId>
        <version>2.0</version>
    </dependency>

    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.4</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

这是发生错误的方法:

private Configuration parseConfig(String path) {
        File configFile = new File(path);
        if(!configFile.exists() || configFile.isDirectory()) {
            // Error config file path invalid
            CustomLogger.warn("ERROR file not found");
        }
        Configurations configs = new Configurations();
        Configuration config = null;
        try {
            config = configs.properties(configFile);
        }
        catch (ConfigurationException cex) {
            // Something went wrong
            CustomLogger.warn("Config Exception");
            cex.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return …
Run Code Online (Sandbox Code Playgroud)

java apache-commons maven

1
推荐指数
1
解决办法
2579
查看次数

标签 统计

apache-commons ×1

java ×1

maven ×1