我很想将 Spring Web MVC 作为 Wildfly 中的一个模块提供服务,但不知何故 servlet ( WebApplicationInitializer
) 似乎没有启动。
模块.xml
modules/org/springframework/4.0.0.RELEASE/module.xml
<module xmlns="urn:jboss:module:1.3" name="org.springframework" slot="4.0.0.RELEASE">
<resources>
<resource-root path="aopalliance-1.0.jar"/>
<resource-root path="spring-aop-4.0.0.RELEASE.jar"/>
<resource-root path="spring-beans-4.0.0.RELEASE.jar"/>
<resource-root path="spring-context-4.0.0.RELEASE.jar"/>
<resource-root path="spring-context-support-4.0.0.RELEASE.jar"/>
<resource-root path="spring-core-4.0.0.RELEASE.jar"/>
<resource-root path="spring-expression-4.0.0.RELEASE.jar"/>
<resource-root path="spring-jdbc-4.0.0.RELEASE.jar"/>
<resource-root path="spring-orm-4.0.0.RELEASE.jar"/>
<resource-root path="spring-tx-4.0.0.RELEASE.jar"/>
<resource-root path="spring-web-4.0.0.RELEASE.jar"/>
<resource-root path="spring-webmvc-4.0.0.RELEASE.jar"/>
<resource-root path="spring-mobile-device-1.1.1.RELEASE.jar"/>
</resources>
</module>
然后我回到我的 Maven 项目并使用 scope 限定所有依赖项provided
。在 Wildfly 中部署项目时,一切似乎都很好。
20:47:27,166 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-13) Adding dependency ModuleDependency [identifier=org.springframework:4.0.0.RELEASE, moduleLoader=Service Module Loader, export=true, optional=false, importServices=false] to module deployment.myapp.war:main
20:47:27,257 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017534: Registered web context: /myapp
20:47:27,269 INFO [org.jboss.as.server] (XNIO-1 task-7) JBAS018559: Deployed "myapp.war" (runtime-name : "myapp.war")
使用捆绑的 Spring 库部署的应用程序运行良好。可能是什么问题呢?