本文整理了Java中org.springframework.beans.factory.BeanCreationException.getMostSpecificCause()
方法的一些代码示例,展示了BeanCreationException.getMostSpecificCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BeanCreationException.getMostSpecificCause()
方法的具体详情如下:
包路径:org.springframework.beans.factory.BeanCreationException
类名称:BeanCreationException
方法名:getMostSpecificCause
暂无
代码示例来源:origin: spring-projects/spring-framework
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
if (logger.isTraceEnabled()) {
logger.trace("Could not determine scripted object type for bean '" + beanName + "': " +
代码示例来源:origin: org.springframework/spring-context
((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
if (logger.isTraceEnabled()) {
logger.trace("Could not determine scripted object type for bean '" + beanName + "': " +
代码示例来源:origin: spring-projects/spring-framework
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: org.springframework/spring-beans
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: org.springframework/spring-beans
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testConstructor() throws Exception {
try {
beanFactory.getBean("constructor");
fail("expected security exception");
}
catch (BeanCreationException ex) {
// expected
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testTrustedFactoryMethod() throws Exception {
try {
beanFactory.getBean("privileged-static-factory-method");
fail("expected security exception");
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testCustomStaticFactoryMethod() throws Exception {
try {
beanFactory.getBean("custom-static-factory-method");
fail("expected security exception");
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testCustomInstanceFactoryMethod() throws Exception {
try {
beanFactory.getBean("custom-factory-method");
fail("expected security exception");
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
代码示例来源:origin: org.springframework/spring-beans
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testNonLenientDependencyMatchingFactoryMethod() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBeanFactoryMethod");
bd.setLenientConstructorResolution(false);
try {
xbf.getBean("lenientDependencyTestBeanFactoryMethod");
fail("Should have thrown BeanCreationException");
}
catch (BeanCreationException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testNonLenientDependencyMatching() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean");
bd.setLenientConstructorResolution(false);
try {
xbf.getBean("lenientDependencyTestBean");
fail("Should have thrown BeanCreationException");
}
catch (BeanCreationException ex) {
// expected
ex.printStackTrace();
assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous"));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAutowireCandidatePatternDoesNotMatch() {
GenericApplicationContext context = new GenericApplicationContext();
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
scanner.setIncludeAnnotationConfig(true);
scanner.setBeanNameGenerator(new TestBeanNameGenerator());
scanner.setAutowireCandidatePatterns("*NoSuchDao");
scanner.scan(BASE_PACKAGE);
try {
context.refresh();
context.getBean("fooService");
fail("BeanCreationException expected; fooDao should not have been an autowire-candidate");
}
catch (BeanCreationException expected) {
assertTrue(expected.getMostSpecificCause() instanceof NoSuchBeanDefinitionException);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
throws BeansException {
String[] beanNames = getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
Map<String, T> result = new LinkedHashMap<String, T>(beanNames.length);
for (String beanName : beanNames) {
try {
result.put(beanName, getBean(beanName, type));
}
catch (BeanCreationException ex) {
Throwable rootCause = ex.getMostSpecificCause();
if (rootCause instanceof BeanCurrentlyInCreationException) {
BeanCreationException bce = (BeanCreationException) rootCause;
if (isCurrentlyInCreation(bce.getBeanName())) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Ignoring match to currently created bean '" + beanName + "': " +
ex.getMessage());
}
onSuppressedException(ex);
// Ignore: indicates a circular reference when autowiring constructors.
// We want to find matches other than the currently created bean itself.
continue;
}
}
throw ex;
}
}
return result;
}
代码示例来源:origin: spring-projects/spring-integration
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithExpression() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidExpression.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();
assertNotNull(cause);
assertTrue(cause instanceof IllegalArgumentException);
assertTrue(cause.getMessage().contains("'delimiters' property is only available"));
throw cause;
}
}
代码示例来源:origin: spring-projects/spring-integration
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithRef() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidRef.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();
assertNotNull(cause);
assertTrue(cause instanceof IllegalArgumentException);
assertTrue(cause.getMessage().contains("'delimiters' property is only available"));
throw cause;
}
}
代码示例来源:origin: spring-projects/spring-integration
@Test(expected = IllegalArgumentException.class)
public void delimitersNotAllowedWithInnerBean() throws Throwable {
try {
new ClassPathXmlApplicationContext("SplitterIntegrationTests-invalidInnerBean.xml",
SplitterIntegrationTests.class).close();
}
catch (BeanCreationException e) {
Throwable cause = e.getMostSpecificCause();
assertNotNull(cause);
assertTrue(cause instanceof IllegalArgumentException);
assertTrue(cause.getMessage().contains("'delimiters' property is only available"));
throw cause;
}
}
内容来源于网络,如有侵权,请联系作者删除!