开发者

Debugging an eclipse / maven project on a remote server?

I use my laptop for development but its resources are limited. I have a local eclipse / maven and my local codebase and I want to keep that because I want to be able to program, compile and junit-test all time.

At my office, I'd like to be able to debug in a production-like scenario, that means, with a big database and and a 8GB RAM java heap.

I thought It shouldn't be too difficult to set up eclipse and maven to put the compiled code on a remote machine, execute a maven process (jetty:run on the remote machine) and attach eclipse for debugging. The remote machine can have its own database and I only have to make sure that the maven repositories are in sync.

Did anyone manage to run this or a similar scenario? I still could not figure out how to put the compiled sources of my ~10 projects on a remote machine. I think running a mav开发者_运维知识库en task and attaching a debugger should be easy with some ssh-magic.


No ssh-magic should really be required unless firewalls are a problem. Just get your project onto the remote somehow, and then run your build with mvnDebug instead of mvn. Maven will listen for a debug connection on port 8000 by default and will wait until you've connected to proceed with the build. Configure a remote debugging launcher in Eclipse, and it will connect and debug like normal. As for getting the code across, you could use rsync, but this is an excellent use case for git. That's how I do this exact thing myself.

Edit: I've never looked for a way to do this with Eclipse, but you can run any arbitrary command from Eclipse, so rsync should work fine. With rsync, you'd want something like

rsync -ruz . <user>@<host>:/<path>

Run that from your project directory, and it should copy the full content of the directory to on the remote host, only copying updated files after the initial copy. You can exclude directories, like target, with the repeatable --exclude option. E.g. --exclude=target. After copying the project, you could start a build with

ssh <user>@<host> mvnDebug <whatever>

The git way might seem a little more arcane if you aren't acquainted with git, but it has the additional benefit of being able to easily make fixes on the remote and pull them back to local. With git, you'd first log in to the remote with ssh, create a project directory, and git init it. AFter that, you can push changes to the remote at any time with

git push -f <user>@<host>:/<path> master

assuming you're working in master, and then on the remote:

git reset --hard
mvnDebug <whatever>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜