close

[Solved] Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found Error Occurs?

Today I am facing the following error Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found in Java.

How To Solve Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found Error ?

  1. How To Solve Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found Error ?

    To Solve Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found Error Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail.

  2. Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found

    To Solve Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found Error Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail.

Solution 1

Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail. I would suggest you to define the input file path as property like @Value("${inputFilePath}"). If you need further initialization in your bean define a void method and annotate it with @PostConstruct and do the initialization within.

Solution 2

Add a public default constructor in your class. For example.

public User() {
}

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read