2014-10-06 27 views
0

我有一个项目被用作许多不同webapps的基础。我试图使用jetty-maven插件在“测试”模式下运行它。在web.xml中使用来自测试范围的过滤器

该项目是一个多模块项目。该过滤器是位于另一个模块,这是我试图运行模块的依赖,像这样规定的:然后

<dependency> 
    <groupId>my.example.test</groupId> 
    <artifactId>test</artifactId> 
    <version>X.X.X</version> 
    <scope>test</scope> 
</dependency> 

从依赖的过滤器类添加为网络过滤器。 XML:

<plugin> 
    <groupId>org.eclipse.jetty</groupId> 
    <artifactId>jetty-maven-plugin</artifactId> 
    <version>9.2.2.v20140723</version> 
    <configuration> 
     <webApp> 
      <contextPath>/test</contextPath> 
      <descriptor>src/test/webapp/WEB-INF/web.xml</descriptor> 
     </webApp> 
     <useTestScope>true</useTestScope> 
     <jvmArgs>some arguments</jvmArgs> 
     <jettyXml>jetty.xml,jetty-ssl.xml,jetty-https.xml</jettyXml> 
     <stopKey>stopJetty</stopKey> 
     <stopPort>12345</stopPort> 
    </configuration> 
</plugin> 

<filter> 
    <filter-name>test</filter-name> 
    <filter-class>my.example.test.test.TestFilter</filter-class> 
</filter> 

<filter-mapping> 
    <filter-name>test</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

最后,该项目通过对码头,Maven插件(mvn jetty:run-forked),这是建立这样一个电话开始

该项目运行并显示index.html文件,但该过滤器从不应用于任何请求。是否可以按照我设置的方式运行测试范围应用程序?还有什么我可以错过?

回答

1

如果服务器启动,没有错误,那么过滤器就在那里。

也许您可以将日志记录添加到筛选器init()doFilter()以验证它是否实际运行。

另外,如果您使用的是javax.websocket,那么这些HTTP/1.1 WebSocket升级请求将不会被过滤。

+0

看来,这两种方法都没有被调用。没有websockets。 – Celos 2014-10-06 12:49:02