close

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

Today We are Going To Solve Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

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

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

    To Fix Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found Error just Add a public default constructor. You can easily solve this error. Here you have to just add a public default constructor in your class. The syntax is given below. And you can use it in that way. It will help you to remove the error. public User() { }

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

    To Fix Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found Error just Define a void method. irst of all, define the input file path as a property like @Value("${inputFilePath}"). Then for further initialization in your bean, you have to define a void method and annotate it @PostConstruct and do the initialization within. By doing this you can get rid of this error.

Solution 1 : Add a public default constructor

You can easily solve this error. Here you have to just add a public default constructor in your class. The syntax is given below. And you can use it in that way. It will help you to remove the error.

public User() {
}

Solution 2 : Define a void method

First of all, define the input file path as a property like @Value("${inputFilePath}"). Then for further initialization in your bean, you have to define a void method and annotate it @PostConstruct and do the initialization within. By doing this you can get rid of this error.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment