Spring autowire with dynamic Constructor Parameter

2019-08-15 02:28发布

问题:

@Component
public class Module {
    public Module(String type, List<String> data) {
        .
        .
        .
    }
}

How do I initialize User, while passing the constructor's parameters, where Module is Autowired into another class: where the parameter values here are dynamic, whereby, for example, they are fetched via a user submission form, thereby can't be stored in a file.

@Component
public class AnotherClass {
    @Autowired
    Module module(....)????? // How do I do it here
    .
    .
    .
}

In this case, type parameter in Constructor it will be fixed and known in the startup. But data is a dynamic parameter.