且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用注解通过Spring执行基于构造函数的依赖项注入?

更新时间:2023-01-11 09:29:34

这里是执行此操作的一种方法:

Here is one way to do this:

@Component 
public class YourBean { 
    @Autowired
    public YourBean(@Value("${prop1}") String arg1, @Value("${prop2}") String arg2) { 
        // rest of the code
    } 
}