简体   繁体   English

WebFilter Java8 和 Maven

[英]WebFilter Java8 and Maven

I am playing with a tutorial and have the following:我正在玩教程并具有以下内容:

*maven project * Maven 项目

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>8.0</version>
    <scope>provided</scope>
</dependency>

*Docker Wildfly 10 *Docker Wildfly 10

FROM jboss/wildfly:10.1.0.Final

*Java Code *Java代码

@WebFilter(urlPatterns = "/*")
public class TokenFilter extends HttpFilter {...}

*And of course the error :) *当然还有错误:)

Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpFilter from [Module "deployment.api.war:main" from Service Module Loader]

Maven marks Java 8 as provided, wildfly should have it. Maven 将 Java 8 标记为已提供,wildfly 应该拥有它。 I am pretty sure I am missing a dependency in maven, but not sure which one.我很确定我缺少 maven 中的一个依赖项,但不确定是哪一个。 The other bits of this software are working just fine (REST bits)该软件的其他部分工作正常(REST 位)

Any hints?任何提示?

I think the problem is, your wildfly version is older than the java-ee version you specified as provided.我认为问题是,您的 wildfly 版本比您指定的 java-ee 版本旧。 (java-ee 8 is released 1 year later than your wildfly version. And HttpFilter class is available since this version) (java-ee 8 比你的 wildfly 版本晚 1 年发布。并且 HttpFilter 类从这个版本开始可用)

If you remove the provided it should work(unless some dependency inconsistencies happens. If that the case you have to upgrade wildfly version)如果您删除所提供的它应该可以工作(除非发生某些依赖性不一致。如果是这种情况,您必须升级wildfly版本)

https://www.oracle.com/corporate/pressrelease/java-se-9-and-ee-8-092117.html https://www.oracle.com/corporate/pressrelease/java-se-9-and-ee-8-092117.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM