Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 我可以依赖于包吗?_Spring_Spring Boot - Fatal编程技术网

Spring 我可以依赖于包吗?

Spring 我可以依赖于包吗?,spring,spring-boot,Spring,Spring Boot,我可以依赖于包吗?包装A注入AImpl,包装B注入BImpl。我不能使用限定符,因为类注入接口是库 可能不会!但是您可以使用@Qualifier来选择所需的bean的特定类型。例如: @Bean("hi") String h1() {return "hi";} @Bean("hello") String h2() {return "hello";} @Bean ApplicationRunner runner(@Qualifier("hi") String str) { return

我可以依赖于包吗?包装A注入AImpl,包装B注入BImpl。我不能使用限定符,因为类注入接口是库

可能不会!但是您可以使用
@Qualifier
来选择所需的
bean的特定类型。例如:

@Bean("hi") String h1() {return "hi";}
@Bean("hello") String h2() {return "hello";}

@Bean ApplicationRunner runner(@Qualifier("hi") String str) {
    return args -> {
        System.out.println(str);
    };
}