jboss spring在web.xml中启动applicationContext

时间:2015-11-18 11:04:12

标签: java spring wildfly applicationcontext

我正在使用wildfly 8.2.0。我想在start上加载spring-config.xml 然而,它没有成功。我做错了什么?

这是我的web.xml。

<?xml version="1.0" encoding="UTF-8"?>

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd”          版本= “3.1” &GT;

<display-name>BQP</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>src/main/resources/spring-config*.xml</param-value>
</context-param>

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


<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>javax.ws.rs.Application</param-name>
    <param-value>com.bionic.rest.ApplicationConfiguration</param-value>
</context-param>
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/rest</param-value>
</context-param>
<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>

1 个答案:

答案 0 :(得分:2)

对于spring MVC,您可以像下面一样加载配置xml表单web.xml 它将在应用程序启动时加载

<!-- Spring MVC     -->
    <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/app-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>