Это сообщение об ошибке, которое я получил
Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}] with root cause org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
ОБНОВЛЕНИЕ:
Это класс, который я пытаюсь связать автоматически. На самом деле это класс обслуживания с параметризованным конструктором.
@Component
@Scope("prototype")
public class RelatedProductService {
private String aa;
private String bb;
private String cc;
@Autowired
public RelatedProductService(String aa, String aa, String orgId, String cc) {
super();
this.aa = aa;
this.bb = bb;
this.cc = cc;
}
...
}
И это то место, где я хочу его использовать, класс контроллера.
@Controller("relatedProductsV1")
@RequestMapping("api/v1/related-products")
@Scope("prototype")
public class RelatedProductsController extends BaseController {
@Autowired
private RelatedProductService relatedProductService;
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getRelatedProducts( @RequestParam(value = "aa", required = true) String aa,
@RequestParam(value = "bb", required = true) String bb,
@RequestParam(value = "cc", required = true) String cc) {
...
String response = relatedProductService.getRelatedProductsResponse();
...
}
}
Надеюсь, это поможет.