4 回答

TA贡献1943条经验 获得超7个赞
从接口 IJobService 中删除 @Service 注释。
public interface JobService {
List<SearchTupleModel> getTuplesFromJobService(List<String> jobIds);
}
@Service
public class JobServiceImpl implements JobService {
}
并将@Controller 添加到您的控制器
@Controller
public class JobSearchResource {
@Autowired
JobService jobService;
}

TA贡献1864条经验 获得超2个赞
包含 main 方法的项目Application.java(或其他名称)文件应位于根目录中,如给定参考中所示:
Application.java 文件应该包含注解@SpringBootApplication ,如果它们被注解为@Service、@Controller、@Configuration等,它将自动扫描所有文件并为它们创建bean ...
或者,如果您想将 Application.java 文件保留在其他包中,则必须在组件扫描注释中明确提及根目录,如下所示:
@SpringBootApplication
@ComponentScan(basePackages = {"com.starterkit.springboot.brs"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

TA贡献1963条经验 获得超6个赞
您可以删除接口 IJobService 上方的@Service吗?
@Service 表示下面的代码是注入的候选者。
由于 IJobService 和 JobService 都有@Service,它会产生 2 个选择,因此 spring 不知道使用哪一个。

TA贡献2065条经验 获得超14个赞
预计至少有 1 个符合自动装配候选条件的 bean。
这个类配置一个spring bean
@Configuration
public class IJobServiceConfig {
@Bean
public IJobService iJobService (){
return new IJobService ();
}
}
还添加@Controller控制器类
添加回答
举报