Teamcity-包javax.servlet不存在

Teamcity-包javax.servlet不存在

如何javax.servlet在 Teamcity 中导入?当我尝试通过 teamcity IntelliJ IDEA 运行器构建 Java 项目时,出现以下错误消息。

这是我第一次使用teamcity,我正在使用这个https://github.com/marekbruchaty/SimpleJavaWebApp项目。我有一个 CentOS 服务器,上面有 teamcity 和 gitlab。

从我的桌面,使用 IntelliJ IDEA,我可以导入 servlet.api 以成功构建。但 teamcity 在另一个位置并进行远程管理,我想知道如何将 servlet-api 导入 teamcity?

我应该在 teamcity 中的哪里添加 servlet-api.jar 作为依赖项以便它可以编译?

这是构建错误:

/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:1: package javax.servlet does not exist
import javax.servlet.ServletException;
                    ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:4: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
                         ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:5: package javax.servlet.annotation does not exist
import javax.servlet.annotation.WebServlet;
                               ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:13: cannot find symbol
  symbol: class HttpServlet
public class FormServlet extends HttpServlet {
                                 ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:12: cannot find symbol
  symbol: class WebServlet
@WebServlet(name = "FormServlet")
 ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:14: cannot find symbol
  symbol:   class HttpServletRequest
  location: class FormServlet
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                          ^
/root/buildAgent/work/f096a35a2a7f853/src/FormServlet.java:14: cannot find symbol
  symbol:   class HttpServletResponse
  location: class FormServlet

答案1

弄清楚了。

我必须将 servlet-api.jar 的路径粘贴到 Build Step -> Project SDKs -> JDK Jar 文件模式中。

相关内容