• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FailureAnalysis类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.boot.diagnostics.FailureAnalysis的典型用法代码示例。如果您正苦于以下问题:Java FailureAnalysis类的具体用法?Java FailureAnalysis怎么用?Java FailureAnalysis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FailureAnalysis类属于org.springframework.boot.diagnostics包,在下文中一共展示了FailureAnalysis类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, Bucket4jGeneralException cause) {
	String descriptionMessage = cause.getMessage();
	String actionMessage = cause.getMessage();
	
	if(cause instanceof JCacheNotFoundException) {
		JCacheNotFoundException ex = (JCacheNotFoundException) cause;
		descriptionMessage = "The cache name name defined in the property is not configured in the caching provider";
		
		actionMessage = "Cache name: " + ex.getCacheName() + newline
				+ "Please configure your caching provider (ehcache, hazelcast, ...)";
	}
	
	if(cause instanceof MissingKeyFilterExpressionException) {
		descriptionMessage = "You've set the 'filter-key-type' to 'expression' but didn't set the property 'expression'";
		actionMessage = "Please set the property 'expression' in your configuration file with a valid expression (see Spring Expression Language)" + newline;
	}
	
	
	return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
 
开发者ID:MarcGiffing,项目名称:bucket4j-spring-boot-starter,代码行数:22,代码来源:Bucket4JAutoConfigFailureAnalyzer.java


示例2: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, QuickFixJBaseException cause) {
	String descriptionMessage = cause.getMessage();
	String actionMessage = cause.getMessage();

	if(cause instanceof ConfigurationException) {
		descriptionMessage = "A configuration error has been detected in the QuickFixJ settings provided.";
		actionMessage = "Please configure your QuickFixJ settings as per the documentation: https://www.quickfixj.org/usermanual/1.6.4//usage/configuration.html";
	}

	if(cause instanceof SettingsNotFoundException) {
		descriptionMessage = "The QuickFixJ settings file could be found.";
		actionMessage = "Please provide a QuickFixJ settings file on the property 'config' for the client/server section in your configuration file.";
	}

	return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
 
开发者ID:esanchezros,项目名称:quickfixj-spring-boot-starter,代码行数:18,代码来源:QuickFixJAutoConfigFailureAnalyzer.java


示例3: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		BeanCurrentlyInCreationException cause) {
	List<String> beansInCycle = new ArrayList<String>();
	Throwable candidate = rootFailure;
	while (candidate != null) {
		if (candidate instanceof BeanCreationException) {
			BeanCreationException creationEx = (BeanCreationException) candidate;
			if (StringUtils.hasText(creationEx.getBeanName())) {
				beansInCycle
						.add(creationEx.getBeanName() + getDescription(creationEx));
			}
		}
		candidate = candidate.getCause();
	}
	StringBuilder message = new StringBuilder();
	int uniqueBeans = beansInCycle.size() - 1;
	message.append(
			String.format("There is a circular dependency between %s beans in the "
					+ "application context:%n", uniqueBeans));
	for (String bean : beansInCycle) {
		message.append(String.format("\t- %s%n", bean));
	}
	return new FailureAnalysis(message.toString(), null, cause);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:BeanCurrentlyInCreationFailureAnalyzer.java


示例4: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, BindException cause) {
	if (CollectionUtils.isEmpty(cause.getFieldErrors())) {
		return null;
	}
	StringBuilder description = new StringBuilder(
			String.format("Binding to target %s failed:%n", cause.getTarget()));
	for (FieldError fieldError : cause.getFieldErrors()) {
		description.append(String.format("%n    Property: %s",
				cause.getObjectName() + "." + fieldError.getField()));
		description.append(
				String.format("%n    Value: %s", fieldError.getRejectedValue()));
		description.append(
				String.format("%n    Reason: %s%n", fieldError.getDefaultMessage()));
	}
	return new FailureAnalysis(description.toString(),
			"Update your application's configuration", cause);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:BindFailureAnalyzer.java


示例5: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, WicketDependencyMismatchDetectedException cause) {
	String descriptionMessage = "One or more Wicket dependencies (jars) doesn't match the wicket-core dependency.\n\r" 
			+"Wicket Core Version: " + cause.getWicketCoreVersion() + newline;
	for(MavenDependency dependency :cause.getDependencies()) {
		descriptionMessage += "\t" + dependency + newline;
	}
	
	String actionMessage = "Please check the Wicket versions configured in your dependency management system (Maven, Gradle, ...) " + newline
			+ "You can disable this check via the property:" + newline
			+ "\twicket.verifier.dependencies.enabled=false." + newline
			+ "You can prevent throwing the exception but still log the detected problems via the property:" + newline
			+ "\twicket.verifier.dependencies.throw-exception-on-dependency-version-mismatch=false";
	
	return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
 
开发者ID:MarcGiffing,项目名称:wicket-spring-boot,代码行数:17,代码来源:WicketDependencyVersionCheckerFailureAnalyzer.java


示例6: shouldAnalyzeConfigurationException

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void shouldAnalyzeConfigurationException() {

    // Given
    QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
    ConfigurationException exception = new ConfigurationException("Error", new RuntimeException());

    // When
    FailureAnalysis analyze = analyzer.analyze(null, exception);

    assertThat(analyze.getAction()).contains("Please configure your QuickFixJ settings");
    assertThat(analyze.getDescription()).contains("A configuration error has been detected in the QuickFixJ settings provided.");
    assertThat(analyze.getCause()).isEqualTo(exception);
}
 
开发者ID:esanchezros,项目名称:quickfixj-spring-boot-starter,代码行数:15,代码来源:QuickFixJAutoConfigFailureAnalyzerTest.java


示例7: shouldAnalyzeSettingsNotFoundException

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void shouldAnalyzeSettingsNotFoundException() {

    // Given
    QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
    SettingsNotFoundException exception = new SettingsNotFoundException("Error", new RuntimeException());

    // When
    FailureAnalysis analyze = analyzer.analyze(null, exception);

    assertThat(analyze.getAction()).contains("Please provide a QuickFixJ settings file");
    assertThat(analyze.getDescription()).contains("The QuickFixJ settings file could be found.");
    assertThat(analyze.getCause()).isEqualTo(exception);
}
 
开发者ID:esanchezros,项目名称:quickfixj-spring-boot-starter,代码行数:15,代码来源:QuickFixJAutoConfigFailureAnalyzerTest.java


示例8: shouldAnalyzeAnyException

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void shouldAnalyzeAnyException() {

    // Given
    QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
    QuickFixJBaseException exception = new QuickFixJBaseException("Error message", new RuntimeException());

    // When
    FailureAnalysis analyze = analyzer.analyze(null, exception);

    assertThat(analyze.getAction()).contains("Error message");
    assertThat(analyze.getDescription()).contains("Error message");
    assertThat(analyze.getCause()).isEqualTo(exception);
}
 
开发者ID:esanchezros,项目名称:quickfixj-spring-boot-starter,代码行数:15,代码来源:QuickFixJAutoConfigFailureAnalyzerTest.java


示例9: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, ConfigurationException cause) {
    String message = cause.getMessage();
    if (cause.getDetailedMessage().isPresent()) {
        message += " - " + cause.getDetailedMessage().get();
    }
    return new FailureAnalysis(message, "Double check the key value", cause);
}
 
开发者ID:kamax-io,项目名称:mxisd,代码行数:9,代码来源:ConfigurationFailureAnalyzer.java


示例10: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, PortInUseException cause) {
	return new FailureAnalysis(
			"Embedded servlet container failed to start. Port " + cause.getPort()
					+ " was already in use.",
			"Identify and stop the process that's listening on port "
					+ cause.getPort() + " or configure this "
					+ "application to listen on another port.",
			cause);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:PortInUseFailureAnalyzer.java


示例11: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure, ValidationException cause) {
	if (cause.getMessage().startsWith(MISSING_IMPLEMENTATION_MESSAGE)) {
		return new FailureAnalysis(
				"The Bean Validation API is on the classpath but no implementation"
						+ " could be found",
				"Add an implementation, such as Hibernate Validator, to the"
						+ " classpath",
				cause);
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:ValidationExceptionFailureAnalyzer.java


示例12: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		BeanNotOfRequiredTypeException cause) {
	if (!Proxy.isProxyClass(cause.getActualType())) {
		return null;
	}
	return new FailureAnalysis(getDescription(cause), ACTION, cause);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:BeanNotOfRequiredTypeFailureAnalyzer.java


示例13: analyze

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		NoUniqueBeanDefinitionException cause) {
	String consumerDescription = getConsumerDescription(rootFailure);
	if (consumerDescription == null) {
		return null;
	}
	String[] beanNames = extractBeanNames(cause);
	if (beanNames == null) {
		return null;
	}
	StringBuilder message = new StringBuilder();
	message.append(String.format("%s required a single bean, but %d were found:%n",
			consumerDescription, beanNames.length));
	for (String beanName : beanNames) {
		try {
			BeanDefinition beanDefinition = this.beanFactory
					.getMergedBeanDefinition(beanName);
			if (StringUtils.hasText(beanDefinition.getFactoryMethodName())) {
				message.append(String.format("\t- %s: defined by method '%s' in %s%n",
						beanName, beanDefinition.getFactoryMethodName(),
						beanDefinition.getResourceDescription()));
			}
			else {
				message.append(String.format("\t- %s: defined in %s%n", beanName,
						beanDefinition.getResourceDescription()));
			}
		}
		catch (NoSuchBeanDefinitionException ex) {
			message.append(String.format(
					"\t- %s: a programmatically registered singleton", beanName));
		}

	}
	return new FailureAnalysis(message.toString(),
			"Consider marking one of the beans as @Primary, updating the consumer to"
					+ " accept multiple beans, or using @Qualifier to identify the"
					+ " bean that should be consumed",
			cause);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:41,代码来源:NoUniqueBeanDefinitionFailureAnalyzer.java


示例14: bindExceptionDueToValidationFailure

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void bindExceptionDueToValidationFailure() {
	FailureAnalysis analysis = performAnalysis(ValidationFailureConfiguration.class);
	assertThat(analysis.getDescription())
			.contains(failure("test.foo.foo", "null", "may not be null"));
	assertThat(analysis.getDescription())
			.contains(failure("test.foo.value", "0", "at least five"));
	assertThat(analysis.getDescription())
			.contains(failure("test.foo.nested.bar", "null", "may not be null"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:BindFailureAnalyzerTests.java


示例15: cyclicBeanMethods

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void cyclicBeanMethods() {
	FailureAnalysis analysis = performAnalysis(CyclicBeanMethodsConfiguration.class);
	assertThat(analysis.getDescription()).startsWith(
			"There is a circular dependency between 3 beans in the application context:");
	assertThat(analysis.getDescription()).contains(
			"one defined in " + CyclicBeanMethodsConfiguration.class.getName());
	assertThat(analysis.getDescription()).contains(
			"two defined in " + CyclicBeanMethodsConfiguration.class.getName());
	assertThat(analysis.getDescription()).contains(
			"three defined in " + CyclicBeanMethodsConfiguration.class.getName());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:BeanCurrentlyInCreationFailureAnalyzerTests.java


示例16: cycleWithAutowiredFields

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void cycleWithAutowiredFields() {
	FailureAnalysis analysis = performAnalysis(CycleWithAutowiredFields.class);
	assertThat(analysis.getDescription()).startsWith(
			"There is a circular dependency between 3 beans in the application context:");
	assertThat(analysis.getDescription()).contains("three defined in "
			+ CycleWithAutowiredFields.BeanThreeConfiguration.class.getName());
	assertThat(analysis.getDescription())
			.contains("one defined in " + CycleWithAutowiredFields.class.getName());
	assertThat(analysis.getDescription())
			.contains(CycleWithAutowiredFields.BeanTwoConfiguration.class.getName()
					+ " (field private " + BeanThree.class.getName());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:BeanCurrentlyInCreationFailureAnalyzerTests.java


示例17: test

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void test() throws Exception {
	try {
		new AnnotationConfigApplicationContext(TestConfiguration.class).close();
		fail("Expected failure did not occur");
	}
	catch (Exception ex) {
		FailureAnalysis analysis = new ValidationExceptionFailureAnalyzer()
				.analyze(ex);
		assertThat(analysis).isNotNull();
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:ValidationExceptionFailureAnalyzerTests.java


示例18: failureAnalysisForFieldConsumer

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void failureAnalysisForFieldConsumer() {
	FailureAnalysis failureAnalysis = analyzeFailure(
			createFailure(FieldConsumer.class));
	assertThat(failureAnalysis.getDescription())
			.startsWith("Field testBean in " + FieldConsumer.class.getName()
					+ " required a single bean, but 6 were found:");
	assertFoundBeans(failureAnalysis);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:NoUniqueBeanDefinitionFailureAnalyzerTests.java


示例19: failureAnalysisForMethodConsumer

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void failureAnalysisForMethodConsumer() {
	FailureAnalysis failureAnalysis = analyzeFailure(
			createFailure(MethodConsumer.class));
	assertThat(failureAnalysis.getDescription()).startsWith(
			"Parameter 0 of method consumer in " + MethodConsumer.class.getName()
					+ " required a single bean, but 6 were found:");
	assertFoundBeans(failureAnalysis);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:NoUniqueBeanDefinitionFailureAnalyzerTests.java


示例20: failureAnalysisForConstructorConsumer

import org.springframework.boot.diagnostics.FailureAnalysis; //导入依赖的package包/类
@Test
public void failureAnalysisForConstructorConsumer() {
	FailureAnalysis failureAnalysis = analyzeFailure(
			createFailure(ConstructorConsumer.class));
	assertThat(failureAnalysis.getDescription()).startsWith(
			"Parameter 0 of constructor in " + ConstructorConsumer.class.getName()
					+ " required a single bean, but 6 were found:");
	assertFoundBeans(failureAnalysis);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:NoUniqueBeanDefinitionFailureAnalyzerTests.java



注:本文中的org.springframework.boot.diagnostics.FailureAnalysis类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommandStackListener类代码示例发布时间:2022-05-22
下一篇:
Java ProxyUriUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap