Spring component with constructor argument

Components are by default singleton, so Spring tries to create the singleton instance, but it can’t figure out what to specify as the parameter.

Since that component is not intended to be used as a singleton, you need to change the scope to prototype.

@Component
@Scope("prototype")
public class DuoLogger {

See the Spring Framework Documentation, section 1.5. Bean Scopes, for more information about scopes.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top