私はSpring 3の注釈駆動型コントローラーとサービスのいくつかを扱っていますが、これがどのように可能になるかについて質問がありましたか?
私の
servlet-context.xml
ファイルには、次のアイテムをロードするためのパスがあります。<context:component-scan base-package="com.project.controller, com.project.service"/>
コントローラーの下では、init クラスにこれがあり、init は次のようにタグ付けされています。
@PostConstruct
public void init() {
ApplicationContext context = new GenericApplicationContext();
bizServices = (BizServices) context.getBean("bizServices");
}
私のサービスには、次のようにタグ付けされたサービスの Bean があります。
@Service("bizServices")
public class BizServicesImpl implements BizServices { ... }
次のように例外が発生します。
SEVERE: Allocate exception for servlet Spring MVC Dispatcher Servlet
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bizServices' is defined
これは、間違ったアプリケーション コンテキスト サービスを使用しているか、Bean が見つからないことを示しています。Autowire を使用せずに PostConstruct でこの Service クラスを明示的に見つけてロードできますか? サービス クラスをファクトリからロードした場合、ファクトリ クラスを指定できますか?それは xml の Bean 構成エントリになりますか?
再度、感謝します...