当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchBeanDefinitionException类代码示例

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


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

示例1: getType

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
	String beanName = BeanFactoryUtils.transformedBeanName(name);

	Object bean = this.beans.get(beanName);
	if (bean == null) {
		throw new NoSuchBeanDefinitionException(beanName,
				"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
	}

	if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
		// If it's a FactoryBean, we want to look at what it creates, not the factory class.
		return ((FactoryBean<?>) bean).getObjectType();
	}
	return bean.getClass();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:StaticListableBeanFactory.java

示例2: getBean

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
/**
 * 先使用类的缩写,再使用类全称来查找
 * @param pageClsStr pageClsStr
 * @return pageClsStr
 */
private Object getBean(String pageClsStr)
{
	String beanName = convertBeanName(pageClsStr);
	
	Object obj = null;
	
	try
	{
		obj = context.getBean(beanName);
	}
	catch(NoSuchBeanDefinitionException e)
	{
		obj = context.getBean(pageClsStr);
	}
	
	return obj;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:23,代码来源:Phoenix.java

示例3: init

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@PostConstruct
public void init() {
	if (!configuration.isInitialize()) {
		LOGGER.debug(() -> "Initialization disabled (not running DDL scripts) for data context id: ["
				+ getDataContextId().orElse("DEFAULT") + "]");
		return;
	}
	DataSource dataSource = null;
	try {
		dataSource = applicationContext.getBean(dataSourceBeanName, DataSource.class);
	} catch (@SuppressWarnings("unused") NoSuchBeanDefinitionException | BeanNotOfRequiredTypeException e) {
		// ignore
	}
	if (dataSource == null) {
		LOGGER.debug(() -> "No DataSource found using bean name " + dataSourceBeanName + ": skip initialization");
		return;
	}
	runSchemaScripts(dataSource);
}
 
开发者ID:holon-platform,项目名称:holon-jdbc,代码行数:20,代码来源:DataContextDataSourceInitializer.java

示例4: getAuthenticationComponent

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
protected AuthenticationComponent getAuthenticationComponent(String instanceId)
{
    ApplicationContext context = this.applicationContextManager.getApplicationContext(instanceId);
    if(context != null)
    {
        try
        {
            AuthenticationComponent authenticationComponent = (AuthenticationComponent) context
                .getBean(sourceBeanName);
            return authenticationComponent;
        }
        catch (NoSuchBeanDefinitionException e)
        {
            return null;
        }
    }
 
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:SubsystemChainingAuthenticationComponent.java

示例5: afterPropertiesSet

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    ParameterCheck.mandatory("authenticationContextManager", authenticationContextManager);

    //Attempt to get RepositoryAuthenticationDao from the subsystem
    for(String contextName : authenticationContextManager.getInstanceIds())
    {
        ApplicationContext ctx = authenticationContextManager.getApplicationContext(contextName);
        try
        {
            authenticationDao = (RepositoryAuthenticationDao)
                    ctx.getBean(RepositoryAuthenticationDao.class);
        } catch(NoSuchBeanDefinitionException e) {}
    }

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:AdminUserPatch.java

示例6: getTypedItem

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
protected ActionDefinition getTypedItem(Item item)
{
    final String actionDefId = item.getId();

    ActionDefinition actionDef = null;
    try
    {
        actionDef = actionService.getActionDefinition(actionDefId);
    }
    catch (NoSuchBeanDefinitionException nsbdx)
    {
        // Intentionally empty.
    }
    
    if (actionDef == null)
    {
        throw new FormNotFoundException(item);
    }
    
    return actionDef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ActionFormProcessor.java

示例7: makeItemData

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
protected Object makeItemData(ActionDefinition item)
{
    ActionItemData actionItemData = null;
    try
    {
        Action action = actionService.createAction(item.getName());
        actionItemData = new ActionItemData(item, action);
    }
    catch (NoSuchBeanDefinitionException nsbdx)
    {
        throw new FormException("Failed to create action '" + item.getName() + "'", nsbdx);
    }
    
    return actionItemData;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ActionFormProcessor.java

示例8: getSourceApplicationContextFactory

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
private ApplicationContextFactory getSourceApplicationContextFactory()
{
    if (sourceApplicationContextFactory != null)
    {
        return sourceApplicationContextFactory;
    }
    else
    {
        try
        {
            return applicationContext.getBean(sourceApplicationContextFactoryName, ApplicationContextFactory.class);
        } catch (NoSuchBeanDefinitionException e)
        {
            return null;
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:SubsystemProxyFactory.java

示例9: beanDoesNotExist

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
/**
 * given that the bean does not exist ensure that an exception is thrown
 */
@Test
public void beanDoesNotExist()
{
    // === given ===

    // set the bean names
    beanExtender.setBeanName(BEAN_NAME);
    beanExtender.setExtendingBeanName(EXTENDING_BEAN_NAME);
    doReturn(false).when(mockedBeanFactory).containsBean(BEAN_NAME);
    doReturn(true).when(mockedBeanFactory).containsBean(EXTENDING_BEAN_NAME);

    // expecting exception
    exception.expect(NoSuchBeanDefinitionException.class);

    // === when ===
    beanExtender.postProcessBeanFactory(mockedBeanFactory);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:BeanExtenderUnitTest.java

示例10: extendingBeanDoesNotExist

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
/**
 * given that the extending bean does not exist ensure that an exception is thrown
 */
@Test
public void extendingBeanDoesNotExist()
{
    // === given ===

    // set the bean names
    beanExtender.setBeanName(BEAN_NAME);
    beanExtender.setExtendingBeanName(EXTENDING_BEAN_NAME);
    doReturn(true).when(mockedBeanFactory).containsBean(BEAN_NAME);
    doReturn(false).when(mockedBeanFactory).containsBean(EXTENDING_BEAN_NAME);

    // expecting exception
    exception.expect(NoSuchBeanDefinitionException.class);

    // === when ===
    beanExtender.postProcessBeanFactory(mockedBeanFactory);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:BeanExtenderUnitTest.java

示例11: getActionDefinitionById

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
public ActionDefinition getActionDefinitionById(String actionDefinitionId)
{
    if (actionDefinitionId == null)
    {
        throw new IllegalArgumentException("Missing actionDefinitionId");
    }

    // Non-existing actionDefinitionId -> 404
    ActionDefinition result = null;
    try
    {
        result = getActionDefinition(actionService.getActionDefinition(actionDefinitionId));
    }
    catch (NoSuchBeanDefinitionException nsbdx)
    {
        // Intentionally empty.
    }

    if (result == null)
    {
        throw new EntityNotFoundException(actionDefinitionId);
    }

    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:ActionsImpl.java

示例12: postProcessBeanFactory

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
	LOGGER.debug(() -> "Lookup @Path and @Provider JAX-RS resource in bean factory [" + beanFactory + "]");

	resources = new ArrayList<>();

	for (String name : beanFactory.getBeanDefinitionNames()) {
		try {
			BeanDefinition definition = beanFactory.getBeanDefinition(name);
			if (!definition.isAbstract()) {
				Class<?> beanClass = BeanRegistryUtils.getBeanClass(name, definition, beanFactory, classLoader);
				if (beanClass != null) {
					if (isJaxrsResourceClass(definition, beanClass)) {
						resources.add(new WeakReference<>(beanClass));
						LOGGER.debug(() -> "Found JAX-RS resource class: [" + beanClass.getName() + "]");
					}
				}
			}
		} catch (@SuppressWarnings("unused") NoSuchBeanDefinitionException e) {
			// ignore
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:24,代码来源:JerseyResourcesPostProcessor.java

示例13: getResourceToInject

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
protected Object getResourceToInject(Object target, String requestingBeanName) {
	if (StringUtils.hasLength(this.beanName)) {
		if (beanFactory != null && beanFactory.containsBean(this.beanName)) {
			// Local match found for explicitly specified local bean name.
			Object bean = beanFactory.getBean(this.beanName, this.lookupType);
			if (beanFactory instanceof ConfigurableBeanFactory) {
				((ConfigurableBeanFactory) beanFactory).registerDependentBean(this.beanName, requestingBeanName);
			}
			return bean;
		}
		else if (this.isDefaultName && !StringUtils.hasLength(this.mappedName)) {
			throw new NoSuchBeanDefinitionException(this.beanName,
					"Cannot resolve 'beanName' in local BeanFactory. Consider specifying a general 'name' value instead.");
		}
	}
	// JNDI name lookup - may still go to a local BeanFactory.
	return getResource(this, requestingBeanName);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:CommonAnnotationBeanPostProcessor.java

示例14: qualifiedBeanOfType

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
/**
 * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a
 * qualifier (e.g. via {@code <qualifier>} or {@code @Qualifier}) matching the given
 * qualifier, or having a bean name matching the given qualifier.
 * @param beanFactory the BeanFactory to get the target bean from
 * @param beanType the type of bean to retrieve
 * @param qualifier the qualifier for selecting between multiple bean matches
 * @return the matching bean of type {@code T} (never {@code null})
 * @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found
 */
public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) {
	if (beanFactory instanceof ConfigurableListableBeanFactory) {
		// Full qualifier matching supported.
		return qualifiedBeanOfType((ConfigurableListableBeanFactory) beanFactory, beanType, qualifier);
	}
	else if (beanFactory.containsBean(qualifier)) {
		// Fallback: target bean at least found by bean name.
		return beanFactory.getBean(qualifier, beanType);
	}
	else {
		throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() +
				" bean found for bean name '" + qualifier +
				"'! (Note: Qualifier matching not supported because given " +
				"BeanFactory does not implement ConfigurableListableBeanFactory.)");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BeanFactoryAnnotationUtils.java

示例15: isFactoryBean

import org.springframework.beans.factory.NoSuchBeanDefinitionException; //导入依赖的package包/类
@Override
public boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException {
	String beanName = transformedBeanName(name);

	Object beanInstance = getSingleton(beanName, false);
	if (beanInstance != null) {
		return (beanInstance instanceof FactoryBean);
	}
	else if (containsSingleton(beanName)) {
		// null instance registered
		return false;
	}

	// No singleton instance found -> check bean definition.
	if (!containsBeanDefinition(beanName) && getParentBeanFactory() instanceof ConfigurableBeanFactory) {
		// No bean definition found in this factory -> delegate to parent.
		return ((ConfigurableBeanFactory) getParentBeanFactory()).isFactoryBean(name);
	}

	return isFactoryBean(beanName, getMergedLocalBeanDefinition(beanName));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractBeanFactory.java


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