开发者

Guice Servlet config doesn't work without Servlet API

开发者 https://www.devze.com 2023-01-24 05:46 出处:网络
The fol开发者_运维技巧lowing Guice Servlet configuration doesn\'t work when I remove the Maven dependency to the Servlet API:

The fol开发者_运维技巧lowing Guice Servlet configuration doesn't work when I remove the Maven dependency to the Servlet API:

filter("/*").through(TransactionFilter.class);

The compiler tells me:

cannot access javax.servlet.Filter
class file for javax.servlet.Filter not found 
   filter("/*").through(TransactionFilter.class);

Any idea?


What do you expect to happen when you remove the Servlet API dependency? Guice Servlet depends on the Servlet API.

Clarification edit: Guice Servlet has a provided scope dependency on the Servlet API so that the jar for it isn't pulled in to the final artifact when building an application... the API classes are provided by the application server at runtime. Thus, you must declare a dependency on the Servlet API in your application's POM yourself (preferably in provided scope as well) in order to use it. This really makes the most sense, though, since you have to declare Servlets and Filters for your application regardless of whether you're using Guice Servlet or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消