Spring.net 如何在web服务上使用Spring Framework.NET注入属性?
我有一个web服务,它具有一个我希望由SpringFramework.NET注入的属性。没有错误消息,但没有注入。我做错了什么 以下是xml文件的内容:Spring.net 如何在web服务上使用Spring Framework.NET注入属性?,spring.net,Spring.net,我有一个web服务,它具有一个我希望由SpringFramework.NET注入的属性。没有错误消息,但没有注入。我做错了什么 以下是xml文件的内容: <object type="MyCompany.MyProject.Business.MyClass"> <property name="PaymentService" ref="PaymentService" /> </object> 这就是我最后要做的。我们必须有一个应用程序上下文:
<object type="MyCompany.MyProject.Business.MyClass">
<property name="PaymentService" ref="PaymentService" />
</object>
这就是我最后要做的。我们必须有一个应用程序上下文:
IPaymentService paymentService = (IPaymentService) SecurityHelper.GetAppContext().GetObject("PaymentService");
public static IApplicationContext GetAppContext()
{
if (WebApplicationContext.Current == null) throw new Exception("Spring not initialized");
IApplicationContext context = WebApplicationContext.Current;
if (context == null) throw new Exception("Spring context not initialized");
return context;
}
您看到了吗?您配置了一个
MyClass
实例,但没有配置一个MyService
实例。请提供更多关于您试图实现的内容以及这是什么类型的应用程序的上下文。
IPaymentService paymentService = (IPaymentService) SecurityHelper.GetAppContext().GetObject("PaymentService");
public static IApplicationContext GetAppContext()
{
if (WebApplicationContext.Current == null) throw new Exception("Spring not initialized");
IApplicationContext context = WebApplicationContext.Current;
if (context == null) throw new Exception("Spring context not initialized");
return context;
}