Spring constructor based dependency injection

You can use constructor-arg tag to pass string literal and you can use value attraibute to pass the name of the Car which you create

So your Car class would be like this

You can create the configuration file with the following code. In this code, I have used constructor-arg with the value attribute

Now you can test the above code with following code