如何在eclipse中调试用ant编译的java项目? [英] How to debug java project compiled with ant in eclipse?

查看:38
本文介绍了如何在eclipse中调试用ant编译的java项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 debian VPS 服务器上托管了一个 java 网站.

I have a java website hosted in a debian VPS server.

当我编写新代码时,我会在本地机器上测试 Web 应用程序,然后再进行部署.

When I write new code, I test the web app in my local machine, before to deploy it.

我在VPS服务器上安装了ant,所以我总是在VPS服务器中编译我的代码,然后将生成的WAR文件放在本地机器上安装的tomcat的webapp文件夹中进行测试.

In the VPS server I have ant installed, so I always compile my code in the VPS server and then I put the generated WAR file in the webapp folder of tomcat installed in my local machine to test.

为了使用 ant 编译源代码,我编写了以下命令.

To compile the source code with ant I write the followings commands.

ant fetch-deps
ant

我需要使用 Eclipse 调试我的网络应用程序.我想要一个调试配置:

I need to debug my web app with eclipse. I'd like to have a debug configuration which:

  • 用蚂蚁编译web项目,和我在VPS里做的一样服务器

  • compiles the web project witn ant, in the same way I do in the VPS server

将生成的war部署到一个tomcat服务器(tomcat服务器在里面
eclipse应该没问题)

deploys the generated war to a tomcat server (tomcat server inside
eclipse should be fine)

打开一个调试会话,这样我就可以在我的代码中放置断点并逐行调试我的应用

opens a debug session, so that I can put break points in my code and debug my app line by line

我已经在 google 中搜索过,但找不到适合我的案例的分步教程.我试图用我在网上到处找到的信息来配置我的调试,但出了点问题......所以我需要一步一步的解释.

I have serached in google, but I can't find a step by step tutorial for my case. I tried to configure my debug with pieces of information I found here and there in the web, but something goes wrong... so I need a step by step explanation.

我试图在我的本地 tomcat 网络服务器中激活调试,但没有命中断点.貌似在使用tomcat的debug session中,eclipse和tomcat都无法正确映射WAR文件和源码.

I tried to activate debug in my local tomcat webserver, but break points were not hitted. It seems that in the debug session with tomcat, eclipse and tomcat are not able to correctly map the WAR file with the source code.

推荐答案

将 Eclipse Oxygen 与新的启动组功能结合使用:

Using Eclipse Oxygen with the new Launch group feature:

  • Build and deploy the war with ant. Deploy with ant explained here.
  • Create a remote debug configuration.
  • Create a Launch group configuration (Run configurations) and add the build and debug configurations to it.

PS:在启动之间添加延迟以允许部署应用.

PS: add a delay between launches to allow app to be deployed.

这篇关于如何在eclipse中调试用ant编译的java项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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