Parameter 0 of Constructor in Required a Bean of Type 'Java.Lang.String' That Could Not Be Found

Class required a bean of type 'java.lang.String' that could not be found

Remove final from sqsQueueMail.

@Value("${aws.sqs.queue.mail}")
private String sqsQueueMail;

That should fix your issue.
Somehow, with @RequiredArgsConstructor, the @Value annotation for the variable is not resolved which made the application to look for a bean of type String

Parameter 0 of constructor in 'com.example..'. required a bean of type 'com.example...' that could not be found

Several ways to resolve this !

  1. Annotate your StudentService class with @Component, during start up of application, Spring will identify this and create a bean in IOC container for use. ( Don't forget to use @ComponentScan(basePackages={com.example.demo.Stude...}) on top of your DemoApplication class )

  2. Create a Configuration class with @Configuration and define your own bean with @Bean returning instance of StudentService

Eventually, use @Autowired on top of your StudentService instance in Controller. Like below

<pre>public class Controller
{
@Autowired
StudentService service;
// so on
} </pre>

springboot: Parameter 0 of method addProduct required a bean of type 'java.lang.String' that could not be found

Remove the @Bean annotation from the addProduct method. That annotation is supposed to be used in configuration classes on methods, which create bean instances.



Related Topics



Leave a reply



Submit