3
我在我的項目中使用Spring 3。然後,我從JAR文件注入spring bean時遇到問題。在JAR文件中,有類似的;我可以從JAR文件注入spring bean嗎?
package test;
@Service("CommonService")
public class CommonService {
}
而且我已經這樣使用它;
package com.java.test.app;
@Service(value = "OtherService")
public class OtherService {
@Resource(name = "CommonService")
private CommonService service;
}
在我的spring-beans.xml中;
<context:component-scan base-package="com.java.test.app, test">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
但@Resource
批註不work.Can我從JAR文件中注入春天豆?
請說明你在jar文件類中定義了@Resource註解的地方嗎? –
@Japs可以在我的jar文件類中聲明'@Resource'註釋。目前不是。 –
當然可以。你需要定義它,否則你不會自動裝配它。 –