简体   繁体   English

如何在Eclipse中调试使用ant编译的Java项目?

[英]How to debug java project compiled with ant in eclipse?

I have a java website hosted in a debian VPS server. 我有一个Java网站托管在Debian VPS服务器中。

When I write new code, I test the web app in my local machine, before to deploy it. 编写新代码时,我先在本地计算机上测试该Web应用程序,然后再进行部署。

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. 在VPS服务器中,我已经安装了ant,因此我总是在VPS服务器中编译代码,然后将生成的WAR文件放入本地计算机中安装的tomcat的webapp文件夹中进行测试。

To compile the source code with ant I write the followings commands. 为了使用ant编译源代码,我编写了以下命令。

ant fetch-deps
ant

I need to debug my web app with eclipse. 我需要使用Eclipse调试Web应用程序。 I'd like to have a debug configuration which: 我想要一个调试配置,其中:

  • compiles the web project witn ant, in the same way I do in the VPS server 以与在VPS服务器中相同的方式编译Web项目

  • deploys the generated war to a tomcat server (tomcat server inside 将产生的战争部署到tomcat服务器(内部的tomcat服务器
    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 打开调试会话,以便我可以在代码中放置断点并逐行调试应用程序

I have serached in google, but I can't find a step by step tutorial for my case. 我已经在Google上学习过,但是找不到适合我的案例的分步教程。 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. 我尝试使用在网络中到处都可以找到的信息来配置调试,但是出了点问题...所以我需要逐步说明。

I tried to activate debug in my local tomcat webserver, but break points were not hitted. 我尝试在本地tomcat Web服务器中激活调试,但是没有遇到断点。 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. 似乎在使用tomcat的调试会话中,eclipse和tomcat无法正确地将WAR文件与源代码映射。

Using Eclipse Oxygen with the new Launch group feature: 将Eclipse Oxygen与新的Launch group功能结合使用:

  • 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: add a delay between launches to allow app to be deployed. PS:在两次启动之间增加延迟 ,以允许部署应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM