Vscode搭建java环境

1、java 插件

  1. Extension Pack for Java
    1. redhat-v0.64.1(支持jdk8)
    2. Maven for java
    3. Debugger for Java-0.37.0
    版本不要安装错,当前时间的最新版本有bug:No delegateCommandHandler for vscode.java.resolveMainMethod
    4. Test Runner for Java
    5. Project Manager for Java
    6. Visual Studio IntelliCode 代码提示功能
    在这里插入图片描述在这里插入图片描述
    注 : 我只安装了前五个

    1. redhat 版本与jdk版本有依赖,jdk8请用redhat-v0.64.1
    2. Debugger for Java要安装0.37.0版本
       最新版本有bug,运行java时报错:No delegateCommandHandler for vscode.java.resolveMainMethod
    4. Visual Studio IntelliCode 我使用了aiXcoder 来代替,基础功能不收费
    
    
  2. koroFileHeader ----- 注释插件(将下面json加入setting最外层{}中)
    快捷键 :
    ctrl+cmd+i 头注释
    ctrl+cmd+t 方法注释
    注 : 头注释和方法注释 需要分别设置内容

    "fileheader.configObj": {
    "createHeader": true,
    "headInsertLine": {//头注释插入第几行
        "php": 2,
        "java": 3,
        "python": 3
    },
    "autoAdd": false,
    "language": {
        "java": {
            "head": "/**",
            "middle": " * @",
            "end": " */",
            "functionSymbol": {
                "head": "/** ",
                "middle": " * @",
                "end": " */"
            }
        },
        "python": {
            "head": "'''",
            "middle": " ",
            "end": "'''",
            "functionSymbol": {
                "head": "'''",
                "middle": " ",
                "end": "'''"
            }
        }
    },
    "fileheader.customMade": {//头注释
        "author": "HMZ",
        "Date": "Do not edit",
        "LastEditTime": "Do not edit"
    },
    "diffEditor.ignoreTrimWhitespace": false,
    "git.enableStatusBarSync": false,
    "explorer.confirmDelete": false,
    "[python]": {
        "editor.defaultFormatter": "ms-python.python"
    },
    "editor.largeFileOptimizations": false,
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": [
        "--style",
        "{column_limit: 400}"
    ],
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": false,
    "python.linting.flake8Args": [
        "--max-line-length=300"
    ],
    
    

2、环境配置

  1. jdk(将下面json加入setting最外层{}中)

      "java.configuration.runtimes": [
    {
      "name": "JavaSE-1.8",
      "path": "/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home",//写bin目录的上一层
      "default": true//启动
    },
    {
      "name": "JavaSE-11",
      "path": "/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home",
      "default": false//不启动
    }]
    
    
    
  2. maven
    注 : settings.xml 默认~/.m2/settings.xml

    "maven.executable.path": "/Users/myhappiness/work/apache-maven-3.2.5/bin/mvn",
    
    

3、格式化工具

找了好多java格式化插件,没有搞懂,最终采用了redhat自带格式化功能

  1. 配置格式化工具
    在setting.json添加设置(将下面json加入setting最外层{}中)

    // ===========java格式化工具================
      "java.format.settings.url": "/Users/[你的电脑用户名]/.vscode/extensions/redhat.java-0.64.1/formatters/eclipse-formatter.xml",
      "[java]": {
        "editor.defaultFormatter": "redhat.java"
      },
      "maven.view": "hierarchical",
      "files.watcherExclude": {
        "**/.bloop": true,
        "**/.metals": true,
        "**/.ammonite": true
      }
    
  2. 配置格式化功能
    文件地址mac:/Users/[你的电脑用户名]/.vscode/extensions/redhat.java-0.64.1/formatters/eclipse-formatter.xml

     1. 格式化时,不格式化注释块
    <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
    

持续更新ing…

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值