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

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

问题描述

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

我在 IntelliJ 中找到了一个配置部分,它位于 Default Setting->Build-executation-deployment->;部署,然后我可以设置远程服务器的地址以及用户名和密码.但我不知道接下来要做什么.

解决方案

有一个

我会

通过工具在远程服务器上运行|外部工具 |你好:

要自动化该过程,请为工件启用 包括在项目构建中,启用 Automatic工具中的上传 |部署并在工具中启用上传外部更改代码> |部署 |选项.

要调试代码,请使用 远程调试配置.复制调试所需的 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天全站免登陆