我希望在Spring Java配置中创建一个Spring bean,并在运行时传递一些构造函数参数。 我已经创建了以下Java配置,在其中有一个bean fixedLengthReport,该bean期望在构造函数中传递一些参数。
@Configuration
public class AppConfig {
@Autowrire
Dao dao;
@Bean
@Scope(value = "prototype")
**//SourceSystem can change at runtime**
public FixedLengthReport fixedLengthReport(String sourceSystem) {
return new TdctFixedLengthReport(sourceSystem, dao);
}
}
但是我遇到了错误,提示sourceSystem无法连接,因为没有找到bean。如何在运行时使用构造函数参数创建bean?
我正在使用Spring 4.2。
SourceSystem
的 bean? - user2004685TdctFixedLengthReport
的实现吗? - user2004685