Home  >  Article  >  Development Tools  >  vscode builds java development environment

vscode builds java development environment

王林
王林Original
2019-12-17 09:21:005222browse

vscode builds java development environment

Environment: The system needs to install jdk1.8, configure the environment variable JAVA_HOME

Open vscode, install java related plug-ins

Language support for Java ™ for Visual Studio Code

Java Extension Pack

Debugger for Java

Java Test Runner

After the above plug-ins are installed, you can start java development.

Personally recommended plug-in

Eclipse Keymap for Visual Studio Code. (eclipse shortcut keys, favorite of eclipse users)

Lombok Annotations Support for VS Code. (Simplified POJO, very pleasant surprise)

Develop basic configuration

Common configuration items: File->Preferences->Settings

1 , maven configuration (if maven is installed locally)

"java.configuration.maven.userSettings": "/home/luokai/maven/apache-maven-3.3.9/conf/settings.xml"

c27e9163aaa9f1a9576fe1f525f65181 It is recommended to use maven Ali warehouse: add ## in settings.xml #

<mirrors>
    <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>

2. Global search ignores folders, and you often need to ignore target files when searching for files.


"search.exclude": {
            "**/node_modules": true,
            "**/bower_components": true,
            "**/target": true,
            "**/logs": true
        }

3. Junit testing, there are problems with the Java Test Runner plug-in running multi-module project tests

GitHub issues have now been resolved: ), in version 0.7.1

recommend a cumbersome way: rely on maven

tasks-> configure tasks

in the tasks array Add the following configuration:

"tasks": [
    {
        "label": "test:HelloWorld",
        "type": "shell",
        "command": "mvn -Dtest=HelloWorldTest#testHelloWorld test",
        "group": "test"
    },

Execute test:command: Run the specified unit test, HelloWorldTest.testHelloWorld() method

Task->Run task

Select just added The test case works perfectly.

4. Use tomcat to debug web projects

(1) Install the Tomcat for Java plug-in

(2) Click the right number of TOMCAT SERVERS in the sidebar and select the locally installed tomcat

(3) Select the war package to run.

PS: Pay attention to building the latest war package before debugging

Tips:

Cancel clicking to open the file to cover the navigation bar:

File->Preferences->Settings, add "workbench.editor.enablePreview": false,

Related article tutorial recommendations:

vscode tutorial

The above is the detailed content of vscode builds java development environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn