在Spring.net for C#中是否有类似于Java@Autowired注释的Spring.net属性?
如果没有,是否有其他方法来指定字段应该是自动设置的?
发布于 2014-01-15 07:38:45
在某种程度上自动加载被支持,但它并不像.Net的其他IOC容器那样先进。
您也可能对CodeConfig项目感兴趣。
发布于 2019-09-16 02:22:25
您可以使用https://github.com/kirov-opensource/NAutowired/blob/master/README.md
[Route("api/[controller]")]
[ApiController]
public class FooController : ControllerBase {
//Use Autowired injection.
[Autowired]
private readonly FooService fooService;
[HttpGet]
public ActionResult<string> Get() {
return fooService == null ? "failure" : "success";
}
}https://stackoverflow.com/questions/21115029
复制相似问题