ApacheCommons配置:ClassNotFoundException:org.apache.Commons.beanutils.dyaBean [英] Apache Commons Configuration: ClassNotFoundException: org.apache.commons.beanutils.DynaBean

查看:22
本文介绍了ApacheCommons配置:ClassNotFoundException:org.apache.Commons.beanutils.dyaBean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的POM包含:

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-configuration2</artifactId>
        <version>2.3</version>
    </dependency>
Quick start guide, Reading a properties file中的两个示例代码:

Configurations configs = new Configurations();
try
{
    Configuration config = configs.properties(new File("config.properties"));
    // access configuration properties
    ...
}
catch (ConfigurationException cex)
{
    // Something went wrong
}

Properties files, Using PropertiesConfiguration

Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
    new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
    .configure(params.properties()
        .setFileName("usergui.properties"));
try
{
    Configuration config = builder.getConfiguration();
    ...
}
catch(ConfigurationException cex)
{
    // loading of the configuration file failed
}

引发:

java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
...
at org.apache.commons.configuration2.builder.fluent.Parameters.createParametersProxy(Parameters.java:307)
at org.apache.commons.configuration2.builder.fluent.Parameters.fileBased(Parameters.java:186)
at properties.PropertiesTest.testLoadAndStoreWithCommonsConfiguration(PropertiesTest.java:52)
...
Caused by: java.lang.ClassNotFoundException: org.apache.commons.beanutils.DynaBean

mvn dependency:tree显示:

...
[INFO] +- org.apache.commons:commons-configuration2:jar:2.2:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.6:compile
[INFO] |  - commons-logging:commons-logging:jar:1.2:compile
...

commons-configuration2's POM包含:

    ...
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.3</version>
        <optional>true</optional><
    /dependency>
    ...

推荐答案

我将the following dependency添加到我的POM中,它起作用了:

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

更新

The latest POM of commons-configuration2(截至10月21日)声明<version>1.9.4。我没有尝试过,但它可能适用于更高版本的Commons配置。

这篇关于ApacheCommons配置:ClassNotFoundException:org.apache.Commons.beanutils.dyaBean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆