0

我有 2 节课:

@Component("baseWebElement")
@Scope("prototype")
@Lazy(true)
public class BaseWebElement implements IBaseWebElement{

@Autowired
private IContextBrowserDriver browserDriver;

private String locator;

@Autowired
public BaseWebElement(String locator)   {
    this.setLocator(locator);
}
...

和:

@Component("webLink")
@Scope("prototype")
@Lazy(true)
public class WebLink implements IUILink, ApplicationContextAware {

private ApplicationContext applicationContext = null;

@Autowired
private IBaseWebElement baseWebElement;

public WebLink(String locator) {

}
...

如您所见,我想在 WebLink 类中使用 BaseWebElement。它们都有一个具有相同参数的构造函数。(定位器)

我想将 WebLink 构造函数参数传递给 BaseWebLink 构造函数。

如何正确使用 Java Spring 注释执行此操作?

谢谢

4

1 回答 1

0

通过使用实例而不是继承来解决。

于 2014-04-22T06:25:42.417 回答