【发布时间】:2016-02-04 17:18:35
【问题描述】:
我收到以下错误:
错误:类 CommonCtx 中的构造函数 Commonctx 不能应用于 给定类型; 必需:org.springframework.core.env.Environment 发现:无参数原因:实际参数列表和形式参数列表不同 长度。
正在使用的代码:
@Component
@PropertySource("file:${input.file.loc}")
public class CommonCtx implements IContext {
private String tempDir;
@Autowired
public CommonCtx(Environment inputProperties) {
tempDir = inputProperties.getProperty("temp.dir");
...
}
@Component
@Conditional(cond1.class)
@PropertySource("file:${input.file.loc}")
public class NewCCtx extends CommonCtx implements NewCContext{
private String productName;
/**
* @param inputProperties
*/
@Autowired
public NewCCtx(Environment inputProperties) {
this.productName = inputProperties.getProperty("product.name");
}
【问题讨论】: