maven can not find package and symbol

回眸只為那壹抹淺笑 提交于 2021-02-16 18:01:20

问题


I have an app with these class: (part of class):

@SessionScoped
@Named
public class UserSessionBean implements Serializable {

    @javax.ws.rs.core.Context private HttpServletRequest httpRequest;

and during mvn compile, I have this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project highway-web: Compilation failure: Compilation failure:
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[28,25] package javax.servlet.http does not exist
[ERROR] 
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[40,38] cannot find symbol
[ERROR] symbol  : class HttpServletRequest
[ERROR] location: class com.kmware.ttk.highway.beans.session.UserSessionBean
[ERROR] -> [Help 1]

While making in IDEA there is no such problems. What it could be?


回答1:


Java file UserSessionBean can not find the class HttpServletRequest.

You should check the dependencies declared in the pom file. Make sure that you include

 <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
  </dependency>

Could you try a mvn clean install and see if it produces the same error.

P.S. Are you running the project from console or from an IDE.



来源:https://stackoverflow.com/questions/13457459/maven-can-not-find-package-and-symbol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!