<util:Eigenschaften, die nicht injiziert, die in java @controller auf webapp bereitgestellt, mit eclipse WTP

Ich bin die Dritte ein maven-Projekt mit spring mvc. Ich habe ein problem mit den Zugriff auf Eigenschaften () mit @value. wenn ich starten Sie tomcat 6, bekomme ich die folgende exception :

09:21:21.703 ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resultsDisplayController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private int foo.ResultsDisplayController.PAGE_SIZE; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'appProperties' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) ~[spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) ~[spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) ~[spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) ~[spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830) [catalina.jar:na]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337) [catalina.jar:na]
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) [catalina.jar:na]
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) [catalina.jar:na]
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) [catalina.jar:na]
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) [catalina.jar:na]
    at org.apache.catalina.core.StandardService.start(StandardService.java:516) [catalina.jar:na]
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) [catalina.jar:na]
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566) [catalina.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_21]
    at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_21]
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) [bootstrap.jar:na]
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) [bootstrap.jar:na]

Hier ist mein foo.resultsDisplayController

@Controller
@Transactional(readOnly = true)
public class ResultsDisplayController {

    private static final Logger LOG = LoggerFactory.getLogger(ResultsDisplayController.class);

    @Value("#{appProperties.page_default_size}")
    private int PAGE_SIZE;

@RequestMapping(value = "/show-results", method = RequestMethod.GET)
    public String displayVariousreults(Model model) {
...
}

}

den Inhalt servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:spring-configured />
    <context:component-scan base-package="foo" />

    <annotation-driven />
    <tx:annotation-driven />

<!-- properties -->
    <util:properties id="appProperties" location="classpath:app.properties" />

    <resources mapping="/resources/**" location="/resources/" />

    <beans:bean id="localeResolver"
        class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />

    <interceptors>
        <beans:bean
            class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <beans:property name="paramName" value="language" />
        </beans:bean>
    </interceptors>

    <beans:bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <beans:property name="basenames">
            <beans:list>
                <beans:value>classpath:labels</beans:value>
            </beans:list>
        </beans:property>
        <beans:property name="cacheSeconds" value="5" />
        <beans:property name="defaultEncoding" value="UTF-8" />
        <beans:property name="fallbackToSystemLocale" value="false" />
    </beans:bean>

    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <beans:bean
        class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <beans:property name="order" value="0" />
        <beans:property name="mediaTypes">
            <beans:map>
                <beans:entry key="json" value="application/json" />
                <beans:entry key="xml" value="text/xml" />
            </beans:map>
        </beans:property>
        <beans:property name="defaultContentType" value="application/json" />
    </beans:bean>

    <beans:bean id="authenticationListener"
        class="foo.AuthenticationListener" />
</beans:beans>

den Inhalt der app.Eigenschaften : page_default_size=10

EDIT:

Ich doscovered, dass das problem mit eclipse wtp. Wenn ich bereitstellen, die webapp auf dem tomcat mit eclipse tritt das problem auf. Wenn ich jedoch bei der Bereitstellung des Krieges ganarated von maven auf einem anderen tomcat-server, unabhängig von eclipse, habe ich nicht das problem und die Anwendung funktioniert gut. Die Frage ist, wie man dieses Problem beheben eclipse-wtp-bug?

InformationsquelleAutor yostane | 2011-09-30
Schreibe einen Kommentar