Spring autowire with dynamic Constructor Parameters using annotation approach

时光毁灭记忆、已成空白 提交于 2019-12-14 02:39:19

问题


@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.

来源:https://stackoverflow.com/questions/34046451/spring-autowire-with-dynamic-constructor-parameters-using-annotation-approach

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!