Maven找不到包和符号

Maven找不到包和符号

问题描述:

我有一个具有以下课程的应用:(课程的一部分):

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;

在mvn编译期间,出现此错误:

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]

在IDEA中制作时不会出现此类问题.可能是什么?

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

Java文件UserSessionBean找不到类HttpServletRequest.

Java file UserSessionBean can not find the class HttpServletRequest.

您应该检查pom文件中声明的依赖项.确保您包含

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>

您可以尝试执行mvn全新安装,看看是否会产生相同的错误.

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

P.S.您是从控制台还是从IDE运行项目.

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