-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autowired(name: )可以是对象属性? #29
Comments
是付本地配置文件吗 |
目前好像还不支持Autowired支持SPEL表达式配置获取 |
已发布新版本 使用方式请参考: eb8c1d0#diff-e5de6f408d0b3e05038c58a88f70cf91b99b9aba7e59372a8b288b7d9de2e23e spel表达式关于 ${} 和 #{} 请参考 |
需要从nuget下新的依赖? |
class A
} |
升级最新版 看这个单测 Autofac.Annotation/test/issue29/TestAutowiredWithValue.cs Lines 105 to 132 in 59aaa08
配置文件: https://github.com/yuzd/Autofac.Annotation/blob/master/test/appsettings.json#L9
|
配置文件路径和名字不需要指定吗?配置文件名字不是appsetings.json |
默认是appsetings.json |
class A [Autowired(“${abc}”)] IValue能结合Autowired吗,这样动态加载类型 |
你这么用不对吧 你这样用的方式如果仅仅是为了动态加载类的话,可以直接用Autowired的就行了 |
动态加载类的话,可以直接用Autowired的就行了 |
你可以试下上面那样的使用方式 [Autowired("${test}")]
public ObjectFactory<A38> A38 {get;set;} 先读,然后sleep(10s ) 然后sleep完成后在去拿 check是不是变成了另外的一个实现类 nacos的话之前有做过一个demo |
[Autowired("${test}")] |
因为需要通过这个ObjectFactory拿才能每次拿到新的, |
class A
{
public string str = "test";
}
B有多个子类,每个子类指定名字,将B注入时,使用属性str指向其中的子类。
目前会报错,请问可以这样实现吗?
class A
{
public const string str = "test";
}
const就没问题,但是我想从配置文件读取相应的子类名字,启动对应的子类。str的值实际上从配置文件获取,就不能时const。
The text was updated successfully, but these errors were encountered: