使用Intellij在远程服务器上部署/调试java代码 [英] deploy/debug java code on a remote server using Intellij

查看:1149
本文介绍了使用Intellij在远程服务器上部署/调试java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在远程服务器上运行我的java代码以获得更快的速度(服务器非常强大)。我想要的是将Intellij连接到该远程服务器并运行我的代码。但是我想在本机(即我的笔记本电脑)上仍然使用IntelliJ。



我在IntelliJ中找到了一个位于默认设置 - >构建 - 执行部署 - >中的配置部分。部署,我可以设置我的远程服务器的地址,用户名和密码。但我不知道下一步该怎么办

解决方案

有一个





我会



远程服务器通过工具 | 外部工具 | hello





要使自动化进程启用在项目构建中包含该工件,启用自动上传 code>工具 | 部署并启用上传工具中的外部更改 部署 | 选项



要调试代码,请使用远程调试配置。复制调试所需的JVM选项,并调整远程SSH外部工具中的选项,以便应用程序以调试模式启动并可以接受连接(确保防火墙规则被调整为允许指定端口上的连接)。




I want to run my java code on a remote server for faster speed (The server is very powerful). What I want is to connect my Intellij to that remote server and run my code. But I want to still use the IntelliJ on my local machine (i.e. my laptop).

I found a config section in IntelliJ which is in Default Setting->Build-executation-deployment-> Deployment and there I can set the address of my remote server and username and password. But I don't know what to do next.

解决方案

There is a step by step deployment guide for PhpStorm, but for IntelliJ IDEA it would be almost the same.

Here is the example configuration for deploying a .jar file from artifact subdirectory to the remote server via SFTP into /home/serge/artifact directory:

I'd configure the artifact to produce the executable jar. Then adjust the deployment configuration to deploy the jar to the remote server. Or you can use Maven/Gradle to do the same.

Next, you can configure Remote SSH external tool to run the jar on the server (via java -jar jarname.jar:

Running on the remote server via Tools | External Tools | hello:

To automate the process enable Include in project build for the artifact, enable Automatic upload in Tools | Deployment and enable uploading of external changes in Tools | Deployment | Options.

To debug the code use Remote Debug configuration. Copy the JVM options needed for debug and adjust the options in your remote SSH external tool so that the app is started in debug mode and can accept connections (make sure firewall rules are adjusted to permit the connections on the specified port).

这篇关于使用Intellij在远程服务器上部署/调试java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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