小编abc*_*bcd的帖子

SnakeYaml 类未找到异常

当我使用 SnakeYaml 1.14 解析 config.yaml 时,出现“未找到类异常”。以下是用于解析的代码。我已经使用 maven 来构建项目。

public class AppConfigurationReader 
{
    private static final  String CONFIG_FILE = "config.yaml";
    private static String fileContents = null;
    private static final Logger logger = LoggerFactory.getLogger(AppConfigurationReader.class);

    public static synchronized AppConfiguration getConfiguration() {
        return getConfiguration(false);
    }

    public static synchronized AppConfiguration getConfiguration(Boolean forceReload) {
        try {
            Yaml yaml = new Yaml();

            if(null == fileContents || forceReload) {
                fileContents = read(CONFIG_FILE);
            }
            yaml.loadAs(fileContents, AppConfiguration.class);
            return yaml.loadAs(fileContents, AppConfiguration.class);
        }
        catch (Exception ex) {
            ex.printStackTrace();
            logger.error("Error loading fileContents {}", …
Run Code Online (Sandbox Code Playgroud)

snakeyaml maven-3

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

标签 统计

maven-3 ×1

snakeyaml ×1