我有一个在WebSphere App Server v8.5上运行的spring项目,我正在尝试使用WebApplicationInitializer删除我的web.xml,但它似乎没有工作。
这是初始化程序:
public class InflowInitializer implements WebApplicationInitializer{
@Override
public void onStartup(ServletContext container) throws ServletException {
System.out.println("In initializer");
}
}
我的spring-web,spring-mvc和javax.servlet-api都包含在我的pom中。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fmr.bpo.asyncprocessingframework</groupId>
<artifactId>apf-inflow-web</artifactId>
<version>1.0.0-M3</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.fmr.bpo.asyncprocessingframework</groupId>
<artifactId>apf-base</artifactId>
<version>1.0.0-M3</version>
</dependency>
<dependency>
<groupId>com.fmr.bpo.asyncprocessingframework</groupId>
<artifactId>apf-base-xen-parser</artifactId>
<version>1.0.0-M3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-jms</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-http</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
</dependencies>
这是一个动态的Web模块3.0项目,我正在使用Java 6进行编译。
除了实现WebApplicationInitializer之外,我还需要做些什么来实现这个目的吗?容器应该扫描并拾取任何实现接口的类吗?我想通过onStartup加载我所有的弹簧配置,但是当我将应用程序部署到服务器时,控件永远不会到达那里。
文档说我需要一个servlet 3.0容器。我真的不知道如何验证我是否正在运行。 WebSphere 8.5是相对较新的,因此我想它将运行3.0。
感谢您的帮助,谢谢。
修改
添加依赖关系树:
[INFO] com.fmr.bpo.asyncprocessingframework:apf-inflow-web:war:1.0.0-M3
[INFO] +- com.fmr.bpo.asyncprocessingframework:apf-base:jar:1.0.0-M3:compile
[INFO] +- com.fmr.bpo.asyncprocessingframework:apf-base-xen-parser:jar:1.0.0-M3:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- javax:javaee-api:jar:6.0:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.springframework.integration:spring-integration-jms:jar:4.2.1.RELEASE:compile
[INFO] | +- org.springframework.integration:spring-integration-core:jar:4.2.1.RELEASE:compile
[INFO] | | +- org.springframework:spring-messaging:jar:4.2.2.RELEASE:compile
[INFO] | | +- org.springframework.retry:spring-retry:jar:1.1.2.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:4.2.2.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework:spring-jms:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework.integration:spring-integration-http:jar:4.2.1.RELEASE:compile
[INFO] +- org.springframework.integration:spring-integration-java-dsl:jar:1.1.0.RELEASE:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.0:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.2.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.2.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.2.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.2.2.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.2.2.RELEASE:compile
[INFO] +- com.google.code.gson:gson:jar:2.4:compile
[INFO] +- io.fastjson:boon:jar:0.33:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.4:compile
[INFO] +- javax.activation:activation:jar:1.1.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- javax.mail:mail:jar:1.4.5:compile
[INFO] \- org.springframework.integration:spring-integration-mail:jar:4.2.1.RELEASE:compile
[INFO] \- org.springframework:spring-context-support:jar:4.2.2.RELEASE:compile