Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command pattern in spring #39850

Closed
faspeee opened this issue Mar 7, 2024 · 1 comment
Closed

Command pattern in spring #39850

faspeee opened this issue Mar 7, 2024 · 1 comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid

Comments

@faspeee
Copy link

faspeee commented Mar 7, 2024

Hi!!

I am working in a project that use the command pattern, But the implementation of its use a combination between field injection and constructor injection.

For example

@Component
public class CustomCommand extends BaseCommand {
    @Autowired
    private CustomService customService;
    
    private final String element;
    
    public CustomCommand(String element){
        this.element = element;
    }
}

This command is called using BeanFactory.getBean(CustomCommand.class, "string").

I did see the next video https://www.youtube.com/watch?v=_IPhpgzpm9w where the implementation use the Factory desing pattern and the custom command are'nt the @Component.

Why shouldn't I use the first approach?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 7, 2024
@wilkinsona
Copy link
Member

As with #39849, this sort of question doesn't belong here. Please respect our wishes as maintainers of this project and use Stack Overflow for questions.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants