Apache Commons Configuration:ClassNotFoundException:org.apache.commons.beanutils.DynaBean

杰罗德·布罗泽(Gerold Broser)

我的POM包含:

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

快速入门指南,读取属性文件中的两个示例代码

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

Properties文件,使用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的POM包含:

    ...
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.3</version>
        <optional>true</optional><
    /dependency>
    ...
杰罗德·布罗泽(Gerold Broser)

我将以下依赖项添加到我的POM中,并且有效:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

org.apache.commons.beanutils copyProperties忽略字段

apache commons beanutils,如何设置属性值?

Spring Boot Tiles-java.lang.NoClassDefFoundError:org / apache / commons / beanutils / MethodUtils

如何使用Apache Commons BeanUtils设置日期类型值,

正确使用Apache Commons Configuration

java.lang.ClassNotFoundException:org.apache.commons.digester.Rule

java.lang.ClassNotFoundException:org.apache.commons.fileupload.FileItemFactory

java.lang.ClassNotFoundException:org.apache.commons.lang.UnhandledException

org.apache.commons.lang.SerializationException:java.lang.ClassNotFoundException

java.lang.ClassNotFoundException:org.apache.commons.text.WordUtils

ClassNotFoundException:带有Maven的org.apache.commons.cli.ParseException

Maven-ClassNotFoundException:org.apache.commons.lang.StringUtils

java.lang.ClassNotFoundException:org.apache.commons.logging.Log

错误:NoClassDefFoundError:org / apache / commons / logging / LogFactory

缺少org.apache.commons.collections.CollectionUtils

NoClassDefFoundError:org.apache.commons.lang.StringUtils

Apache Commons FTP问题

Apache Commons CLI(选项)

Apache Commons FTPClient挂起

Google Guava与Apache Commons

Apache Commons Unzip方法?

PropertyPlaceholderConfigurer从XML文件读取(Apache Commons Configuration)

Python是否等同于org.apache.commons.configuration?

Apache-Commons Commons-Functor的状态

Commons beanutils替代

Apache Commons CLI参数值

Apache Class Commons Math的NoClassDefFoundError

Apache commons 配置 spring 集成

Apache Commons FTPClient.listFiles