Maven找不到包和符号 [英] maven can not find package and symbol

查看:191
本文介绍了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.

这篇关于Maven找不到包和符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆