启动期间发生spring Gulp异常

byqmnocz  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(406)

我有豆子(不介意) try catch 用于调试):

@Bean
    public IgniteEntityConfiguration articleIgniteEntityConfig() {
        try {
            return IgniteEntityConfiguration.builder()
                    .cacheName("ArticleCache")
                    .dbTableName("ARTICLE")
                    .valueClass(Article.class)
                    .build();
        } catch (Exception e) {
            log.error("bean errr", e);
            throw e;
        }

    }

IgniteEntityConfiguration 我验证传递的类并在需要时抛出异常。

流量

在我的日志中:
记录器记录的错误 log.error("bean errr", e); ;
其他信息行。
@controller使用intercity使用的bean时出错 articleIgniteEntityConfig ; 在这里应用程序停止。
如果我删除 try catch 块,甚至没有记录错误(抛出异常-我用调试器检查了它)。

问题

为什么?beans中的第一个异常不应该停止应用程序吗?

isr3a4wc

isr3a4wc1#

我找到了答案。我没有得到有意义的错误,因为在 IgniteRepositoryFactory (ignite-spring-data琰2.2)所有原因错误均被忽略,仅抛出此错误:

throw new IgniteException("Failed to initialize Ignite repository factory. Ignite instance or"
                        + " IgniteConfiguration or a path to Ignite's spring XML "
                        + "configuration must be defined in the"
                        + " application configuration");

完整方法

private Ignite igniteForRepoConfig(RepositoryConfig config) {
        try {
            String igniteInstanceName = evaluateExpression(config.igniteInstance());
            return (Ignite)ctx.getBean(igniteInstanceName);
        }
        catch (BeansException ex) {
            try {
                String igniteConfigName = evaluateExpression(config.igniteCfg());
                IgniteConfiguration cfg = (IgniteConfiguration)ctx.getBean(igniteConfigName);
                try {
                    // first try to attach to existing ignite instance
                    return Ignition.ignite(cfg.getIgniteInstanceName());
                }
                catch (Exception ignored) {
                    // nop
                }
                return Ignition.start(cfg);
            }
            catch (BeansException ex2) {
                try {
                    String igniteSpringCfgPath = evaluateExpression(config.igniteSpringCfgPath());
                    String path = (String)ctx.getBean(igniteSpringCfgPath);
                    return Ignition.start(path);
                }
                catch (BeansException ex3) {
                    throw new IgniteException("Failed to initialize Ignite repository factory. Ignite instance or"
                        + " IgniteConfiguration or a path to Ignite's spring XML "
                        + "configuration must be defined in the"
                        + " application configuration");
                }
            }
        }
    }

相关问题