Closed youfak closed 3 years ago
是找到问题了所以关闭了是吗?
是的,已经找到问题了
发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用
发件人: FatTigermailto:notifications@github.com 发送时间: 2020年11月12日 13:50 收件人: kirov-opensource/NAutowiredmailto:NAutowired@noreply.github.com 抄送: childmailto:wulincheng02@outlook.com; State changemailto:state_change@noreply.github.com 主题: Re: [kirov-opensource/NAutowired] 在.net core 3.1 中使用 NAutowired.Core 自动注入控制器中得的值为null (#11)
是找到问题了所以关闭了是吗?
― You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/kirov-opensource/NAutowired/issues/11#issuecomment-725854171, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGPBVOHXEARV3HEYH2DFEPDSPNZRBANCNFSM4TS2VBEA.
namespace Com.macao.electron.Respository.ModelRepository { ///
/// 用户数据接口类
///
[Repository]
public partial class UserRepository
{
}
namespace Com.macao.electron.Service { ///
/// User 业务接口类
///
public interface IUserService
{
string getTest();
}
}
namespace Com.macao.electron.ServiceImpl { ///
/// User 业务接口类
///
[Service]
public partial class UserServiceImpl:IUserService
{
[Autowired]
private UserRepository UserDao { get; set; }
} }
在Startup.cs 配置如下: //将控制器注册为服务 services.AddControllers().AddControllersAsServices(); services.Replace(ServiceDescriptor.Transient<IControllerActivator, NAutowiredControllerActivator>()); //使用自动依赖注入并指定已添加特性的程序集 services.AutoRegisterDependency(new List { "Com.macao.electron.Respository", "Com.macao.electron.Service", "Com.macao.electron.ServiceImpl", "Com.macao.electron" });
namespace Com.macao.electron.Controllers { [Route("[controller]")] [ApiController] public class AuthController : ControllerBase {
} }