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

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

问题描述

我有一个Java网站托管在Debian VPS服务器中.

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.

在我安装了ant的VPS服务器中,所以我总是在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调试我的Web应用程序.我想要一个调试配置,

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

  • 以与在VPS中相同的方式编译Web项目 服务器

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

将生成的War部署到tomcat服务器(内部的tomcat服务器
月食应该可以)

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 Web服务器中激活调试,但是没有遇到断点.似乎在使用tomcat的调试会话中,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天全站免登陆