當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。