2014-04-29 106 views
0

在我的Eclipse的webapp中,當啓動web項目時,我的xml配置文件從不加載。 你能解釋一下我可以如何將src/main/webapp/WEB-INF中的xml文件添加到上下文加載器中嗎?maven webapp,xml永不加載

我的3個文件分別是:

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
version="3.0"> 

<welcome-file-list> 
    <welcome-file> 
     index.jsp 
     index.html 
    </welcome-file> 
</welcome-file-list> 


<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
/WEB-INF/application-context.xml, 
/WEB-INF/cxf-servlet.xml 
</param-value> 
</context-param> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<servlet> 
    <servlet-name>CXFServlet</servlet-name> 
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
    <servlet-name>CXFServlet</servlet-name> 
    <url-pattern>/*</url-pattern> 
</servlet-mapping> 

CXF-servlet.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xmlns:jaxrs="http://cxf.apache.org/jaxrs" 
    xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> 

<!-- these are included in the dependency jar --> 
<import resource="classpath:META-INF/cxf/cxf.xml"/> 
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 


<!-- soap container --> 
<jaxws:endpoint 
     id="computerWS" 
     implementor="#computerService" 
     address="/computer" 
     /> 
</beans> 

應用程序的context.xml:

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

<import resource="classpath:serviceContext.xml" /> 
<import resource="classpath:bindingContext.xml" /> 

<context:component-scan base-package="com.excilys.formation.webservice.service" /> 

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

<bean id="messageSource" 
    class="org.springframework.context.support.ResourceBundleMessageSource"> 
    <property name="basename" value="messages" /> 
    <property name="defaultEncoding" value="UTF-8" /> 
</bean> 
<bean id="localeResolver" 
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> 
    <property name="defaultLocale" value="en" /> 
</bean> 

</beans> 

謝謝

回答

0

確保tomcat部署您的應用程序。如果您在基於應用程序的部署過程中沒有收到任何錯誤,則可能是tomcat問題。

+0

嘿,我不知道這是不是一個類似的錯誤,但我做了Maven - >更新項目,並乾淨安裝我的項目。它現在正在工作! – psv