是否可以将 Plexus 组件注入 Mojo。这是我尝试过的,但myComponent
总是null
.
我的组件:
import org.codehaus.plexus.component.annotations.Component;
@Component(role = MyComponent.class, hint = "mine")
public class MyComponent {
}
我的魔力:
import org.codehaus.plexus.component.annotations.Requirement;
import org.apache.maven.plugins.annotations.Component;
public class MyMojo extends AbstractMojo {
@Requirement(role = MyComponent.class, hint = "mine", optional = false)
protected MyComponent myComponent;
@Component
protected MavenProject project;
}