URI的Spring NoSuchBeanDefinitionException

时间:2013-02-26 15:35:35

标签: java spring annotations

我有以下设置:

@Configuration
public class MyBeanFactory{
    @Bean
    public MyBean getMyBean(URI uri){
        return new MyBean(uri);
    }
}
@Named
public class Buz{
    @Inject
    private MyBeanFactory factory;

    public void someMethod(URI someUri){
        MyBean foo = factory.getMyBean(someUri);
        // Do something with Foo
    }
}

当我运行此代码时,我收到以下错误:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No matching bean of type [java.net.URI] found for dependency

如何正确声明在这种情况下使用的URI?

0 个答案:

没有答案