在使用 Eclipse 构建我的Web项目时,一切都很好:没有错误,也没有警告。
然而,在使用 Maven 构建项目时出现了 错误。下面是输出的 mvn compile
结果:
c:\Users\jwa\Desktop\tets\traffic_web>mvn compile -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building traffic_web
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory c:\Users\jwa\Desktop\tets\traffic_web\src\main\resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 22 source files to c:\Users\jwa\Desktop\tets\traffic_web\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\Encryptor.java:[7,15] sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\Session.java:[3,25] package javax.servlet.http does not exist
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\Session.java:[15,21] cannot find symbol symbol: class HttpSession location: class traffic_web.tools.Session
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[6,20] package javax.servlet does not exist
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[7,20] package javax.servlet does not exist
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[8,20] package javax.servlet does not exist
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[10,58] cannot find symbol symbol: class ServletContextListener public class ServletContextListenerInitializer implements ServletContextListener {
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[12,33] cannot find symbol symbol: class ServletContextEvent location: class traffic_web.tools.ServletContextListenerInitializer
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[15,35] cannot find symbol symbol: class ServletContextEvent location: class traffic_web.tools.ServletContextListenerInitializer
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\controller\BoardController.java:[9,25] package javax.servlet.http does not exist
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\controller\BoardController.java:[87,29] cannot find symbol symbol: class HttpServletResponse location: class traffic_web.controller.BoardController
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\controller\BoardController.java:[116,37] cannot find symbol symbol: class HttpServletResponse location: class traffic_web.controller.BoardController
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\Encryptor.java:[27,15] sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\Session.java:[17,27] cannot access javax.servlet.http.HttpServletRequest class file for javax.servlet.http.HttpServletRequest not found return attr.getRequest().getSession(true); // true == allow create
c:\Users\jwa\Desktop\tets\traffic_web\src\traffic_web\tools\ServletContextListenerInitializer.java:[17,8] cannot find symbol symbol: class ServletContext location: class traffic_web.tools.ServletContextListenerInitializer
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven
我的POM文件如下:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>masters.traffic</groupId>
<artifactId>traffic_web</artifactId>
<packaging>war</packaging>
<name>traffic_web</name>
<version>0.1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
有人可以帮我解决这个问题吗?
谢谢!