问题
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