プロパティ ファイルを spring 3.2.2 Web アプリケーションに追加する際に問題があります。
私の Web.xml:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
私の mvc-dispatcher-servlet.xml:
<mvc:default-servlet-handler />
<mvc:annotation-driven />
<context:annotation-config/>
<context:property-placeholder location="/WEB-INF/application.properties"/>
<context:component-scan base-package="com.mypackage.controller" />
<context:component-scan base-package="com.mypackage.model" />
<context:component-scan base-package="com.mypackage.model.service" />
<context:component-scan base-package="com.mypackage.model.serviceImpl" />
また、対応する「コンテキスト」スキーマ定義を xml ヘッダーに追加しました。
さらに、spring-security.xml があります (ここには内容を掲載しません)。
私のクラス com.mypackage.model.serviceImpl.FeatureServiceImpl は、次のように application.properties から読み取ります。
…
@Autowired
private Environment env;
env.getProperty("db.host");
私はこの例外を受け取ります:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'featureController': Injection of autowired dependencies failed;
…
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mypackage.model.serviceImpl.FeatureServiceImpl com.mypackage.controller.FeatureController.featureService;
ここで何が欠けていますか?ありがとう!