gpt4 book ai didi

xml - 为什么在使用 "ant"命令 build.xml 时出现导入错误?

转载 作者:行者123 更新时间:2023-11-28 22:49:26 25 4
gpt4 key购买 nike

我在包含 build.xml 的目录中使用“ant”命令,但导入语句时出现错误。当它到达这一行时,

    <!-- compile.gui -->
<target name="compile.gui" depends="test.properties,compile.api">
<javac srcdir="${src}" destdir="${build.classes}"
classpathref="gui.class.path" debug="on" target="1.8" includeantruntime="false">
<include name="eu/lt4el/gui/**" />
</javac>
</target>

它引用了一个java文件

    package eu.lt4el.gui;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import eu.lt4el.common.DocumentStatus;
import eu.lt4el.AppInterface;
import eu.lt4el.defcontext.Definition;
import org.apache.log4j.Logger;
public class LTStartPage extends HttpServlet
{ . . . .

当它尝试编译 java 文件时出现以下错误:

     compile.gui:
[javac] Compiling 1 source file to /home/ufuoma/Downloads/ltserver/build/classes
[javac] /home/ufuoma/Downloads/ltserver/src/eu/lt4el/gui/LTStartPage.java:3: error: package javax.servlet does not exist
[javac] import javax.servlet.*;
[javac] ^
[javac] /home/ufuoma/Downloads/ltserver/src/eu/lt4el/gui/LTStartPage.java:4: error: package javax.servlet.http does not exist
[javac] import javax.servlet.http.*;
[javac] ^
[javac] /home/ufuoma/Downloads/ltserver/src/eu/lt4el/gui/LTStartPage.java:13: error: cannot find symbol
[javac] public class LTStartPage extends HttpServlet
[javac] ^
[javac] symbol: class HttpServlet
[javac] /home/ufuoma/Downloads/ltserver/src/eu/lt4el/gui/LTStartPage.java:17: error: cannot find symbol
[javac] protected HttpSession session;
[javac] ^
[javac] symbol: class HttpSession
[javac] location: class LTStartPage
[javac] /home/ufuoma/Downloads/ltserver/src/eu/lt4el/gui/LTStartPage.java:33: error: cannot find symbol
...
...
[javac] 17 errors
BUILD FAILED
/home/ufuoma/Downloads/ltserver/build.xml:305: Compile failed; see the compiler error output for details.

我安装了 Tomcat 和 JRE 8,并且正在运行 Ubuntu,但构建失败。我不知道为什么我有错误。谢谢

编辑*类路径在build.xml文件中定义如下:

    <!-- class path for gui -->
<path id="gui.class.path">
<pathelement path="${env.CATALINA_HOME}/common/lib/servlet-api.jar"/>
<pathelement path="${lib}/log4j-1.2.14.jar"/>
</path>

最佳答案

只需运行:

$ export CATALINA_HOME=/opt/tomcat
$ ant

关于xml - 为什么在使用 "ant"命令 build.xml 时出现导入错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45218903/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com