VS Code Remote
@H_403_0@2019 年 5 月 3 日,在 PyCon 2019 大会上,微软发布了 VS Code Remote,开启了远程开发的新时代。 @H_403_0@
- @H_403_0@在部署相同的操作系统上进行开发,或者使用更大或更专业的硬件。
- @H_403_0@把开发环境作为沙箱,以避免影响本地计算机配置。
- @H_403_0@让新手轻松上手,让每个人都保持一致的开发环境。
- @H_403_0@使用原本在本地环境不可用的工具或运行时,或者管理它们的多个版本。
- @H_403_0@在 WSL 里开发 Linux 应用。
- @H_403_0@从多台不同的计算机访问现有的开发环境。
- @H_403_0@调试在其他位置(比如客户网站或云端)运行的应用程序。
安装vs code insiders
@H_403_0@需要先安装最新的内部体验版,https://code.visualstudio.com/insiders/ @H_403_0@然后安装Remote Development插件 @H_403_0@https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack @H_403_0@为了简单起见,我们采用SSH模式。需要先在windows机器安装OpenSSHwindows 10 安装OpenSSH
@H_403_0@使用 PowerShell 安装 OpenSSH @H_403_0@若要安装使用 PowerShell 的 OpenSSH,请首先以管理员身份启动 PowerShell。 若要确保 OpenSSH 功能以安装方式提供: @H_403_0@PowerShell复制Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
# This should return the following output:
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
@H_403_0@然后,安装服务器和/或客户端功能:
@H_403_0@PowerShell复制
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Both of these should return the following output:
Path :
Online : True
RestartNeeded : False
SSH 认证
- 先ssh-keygen生车密钥
- 然后ssh-copy-id 到服务器
ssh-copy-id root@YOUR-SERVER-IP
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/jqpeng/.ssh/id_ed25519.pub"
The authenticity of host 'YOUR-SERVER-IP' can't be established.
ECDSA key fingerprint is SHA256:HRwsmslg5ge+JYcOjW6zRtUxrFeWJ5V2AojlIvLaykc.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s),to filterout any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@YOUR-SERVER-IP's password:
Number of key(s) added: 1
Now try logging into the machine,with: "ssh 'root@YOUR-SERVER-IP'"
and check to make sure that only the key(s) you wanted were added.
使用VS code inside 开发程序
@H_403_0@准备工作:- 确保服务器已有JDK,mvn,没有的话先安装好
- 将代码签出到服务器一个目录
connect to host
:
@H_403_0@然后输入root@YOUR_SERVETR_IP
@H_403_0@调试程序
@H_403_0@打开包含main的java文件,点击调试菜单,会自动生成一个启动文件,配置下即可:{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0","configurations": [
{
"type": "java","name": "AimindWebApplication","request": "launch","mainClass": "com.xxx.xxx.XXXWebApplication"
}
]
}
@H_403_0@然后启动。
@H_403_0@惊喜的发现,在main函数上方,自动出现了RUN|DEBUG,见下图,点击debug即可启动调试
@H_403_0@内存占用
@H_403_0@之前IDEA启动调试后,内存占用2G+,VS code呢?400M+! @H_403_0@@H_403_0@作者:Jadepeng
出处:jqpeng的技术记事本--http://www.cnblogs.com/xiaoqi
您的支持是对博主最大的鼓励,感谢您的认真阅读。
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。