Table of Contents
Premise
vscode About java Plug-in
创建maven工程
第一种
第二种
父子工程
小结
Home Development Tools VSCode Teach you step by step how to create a maven project in vscode (combination of graphics and text)

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

Oct 13, 2021 pm 07:08 PM
maven vscode

How to create a maven project in vscode? The following article will take you step by step to create a maven project through a combination of pictures and texts. I hope it will be helpful to you!

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

Because I am currently learning design patterns, and I am reading the pdf book "Relearning Design Patterns" to summarize and summarize. Of course, I still need to think about it from many aspects and angles. , the design pattern focuses on its ideas and applying its ideas to real life or a certain development scenario.

Another point is that although I use the Go language for work, I don’t want to use Goland. I think it’s too heavy, so I’m used to using vscode. I used to write a lot of python, js, etc., and I also use it to write markdown. vscode, so, like Java, I have started to use vscode since then. I don’t think much about using IDEA. I still think it is too heavy...

Without further ado, let’s start the show...

Premise

I wanted to start directly with the plug-in on vscode, but it seems that I have to mention the installation of Java language first... [Recommended study: "vscode tutorial" 】

I will start with the mac platform. Of course, there are a lot of tutorials on the Internet about the installation of the Java language, so I will not introduce it in detail here.

Mac comes with java, you might as well enter in the terminal

java -version
Copy after login

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

The problem you may encounter is: the built-in mac does not have java. If you have, This part can be ignored...

The path of the built-in java is generally: /Library/Java/JavaVirtualMachines

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

Yes It doesn’t matter if you don’t have it. Let me teach you a trick to use jenv to manage your java version, but I will post the java version mirror download address here

java version mirror download Address

https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/

After downloading, extract it to the path mentioned above...

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

ok, add environment variables, let me declare here, I am using oh-my-zsh, so you can add it in .zshrc, Of course, you can add it in .bash_profile.

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

As shown in the picture above, I can paste the code into the text for easy copying. Of course, you can draw inferences

# added by java jdk 1.8
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
Copy after login

After performing the above operations, you need to usesource .zshrc Refresh the environment variables. At this time, you can use java -version, and the scene shown in the above picture will appear.

Of course, I use jenv to manage multiple versions of java. Regarding how to install jenv, I naturally use mac’s brew:

brew install jenv
Copy after login

Then, like java, add environment variables. Of course, after you install the terminal, you will be prompted to add environment variables in the xxx file:

# jenv
export PATH="$HOME/.jenv/bin:$PATH"
  eval "$(jenv init -)"
Copy after login

At this time, I enter jenv in the terminal , you can see the screen

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

If the above is ok, we can add the version, we can use jenv add, I can give you an example For example, the demonstration is version 11. You can draw inferences:

jenv add /Library/Java/JavaVirtualMachines/jdk-11.0.12+7/Contents/Home
Copy after login

After the addition is successful, you can enter jenv versions

Teach you step by step how to create a maven project in vscode (combination of graphics and text)## on the terminal.

#Switch version:

jenv global 11.0 or jenv local 11.0

No more nonsense, what kind of article is this after all?

vscode creates maven project...The core is here...

Speaking of creating a

Maven project, the premise is that the maven framework is installed on your system. For Mac os systems, you can still use brew to install

brew install maven
Copy after login

. Of course, in addition to

brew, you can also download the binary file from the official website. Remember Add environment variables

Speaking of environment variables, you can add them in

.zshrc, or you can add the corresponding bin file in /usr/local/bin Soft link

After executing the above operation, you can enter

mvn in the terminal to see the effect

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

vscode About java Plug-in

One picture to solve, so convenient

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

After installing the plug-in, press

Ctrl Shift P and enter Java: Configure Java Runtime

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

检查项目、工程等运行时版本

给vscode的maven插件键入setting.xml和可执行文件,分别如下图所示

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

若想测试的话,也不是不可以,演示一下简单工程

使用cmd+shfit+p 输入 Java: create Project,输入项目名,在src文件夹中,选择Run运行Java代码,控制台数据Hello World则为成功。

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

创建maven工程

有两种方式:

第一种

使用cmd+shfit+p 输入 Java: create Project,或出现创建项目的类型,我们选择maven,这样吧,我动图演示一下,如何创建使用第一种方式创建maven工程的...

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

其实我感觉就跟idea创建maven工程师类似的,无非就是选择对应的maven工程,其次选择版本,然后键入各种id名称等,所以和idea创建maven工程大同小异...

不过,虽然我这么说了,但是上面的动图仅仅是第一步,因为你键入一些信息之后,vscode下面调试或者终端区,依然会让你确认一些信息,比如

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

按照提示,一步一步操作即可,这里我就不演示动图了。

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

第二种

第二种,比较简单,直接在下图中添加+号即可

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

父子工程

基于上面创建Maven工程的基础,那么,我们首先有这样的父工程parent-demo

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

在父工程的pom文件中加入一行代码,保存即可,记得重新编译一下pom。

<packaging>pom</packaging>
Copy after login

接着,我们添加子工程

1Teach you step by step how to create a maven project in vscode (combination of graphics and text)

最后,我们看以下图:

Teach you step by step how to create a maven project in vscode (combination of graphics and text)

从上图可以看出,父工程pom文件自动添加

<modules>  
  <module>child-demo001</module>
</modules>
Copy after login

而子工程的pom文件,自动添加

<parent>
  <artifactId>parent-demo</artifactId>
  <groupId>com.example</groupId>
  <version>1.0-SNAPSHOT</version>
</parent>
Copy after login

我们测试一下子工程,测试自动生成的代码

package com.example.child.demo;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}
Copy after login

2Teach you step by step how to create a maven project in vscode (combination of graphics and text)

从上图可以,按照我们的预期,是可以输出Hello World,是的,完全没得问题。

小结

综上,给我的感觉是和idea没什么区别,如果vscode工具比较熟悉的话,很快就掌握其中的使用了。

更多编程相关知识,请访问:编程入门!!

The above is the detailed content of Teach you step by step how to create a maven project in vscode (combination of graphics and text). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to view word documents in vscode How to view word documents in vscode How to view word documents in vscode How to view word documents in vscode May 09, 2024 am 09:37 AM

First, open the vscode software on the computer, click the [Extension] icon on the left, as shown in ① in the figure. Then, enter [officeviewer] in the search box of the extension interface, as shown in ② in the figure. Then, from the search Select [officeviewer] to install in the results, as shown in ③ in the figure. Finally, open the file, such as docx, pdf, etc., as shown below

Caltech Chinese use AI to subvert mathematical proofs! Speed ​​up 5 times shocked Tao Zhexuan, 80% of mathematical steps are fully automated Caltech Chinese use AI to subvert mathematical proofs! Speed ​​up 5 times shocked Tao Zhexuan, 80% of mathematical steps are fully automated Apr 23, 2024 pm 03:01 PM

LeanCopilot, this formal mathematics tool that has been praised by many mathematicians such as Terence Tao, has evolved again? Just now, Caltech professor Anima Anandkumar announced that the team released an expanded version of the LeanCopilot paper and updated the code base. Image paper address: https://arxiv.org/pdf/2404.12534.pdf The latest experiments show that this Copilot tool can automate more than 80% of the mathematical proof steps! This record is 2.3 times better than the previous baseline aesop. And, as before, it's open source under the MIT license. In the picture, he is Song Peiyang, a Chinese boy. He is

How to enable background updates in vscode How to enable background updates in vscode How to enable background updates in vscode How to enable background updates in vscode May 09, 2024 am 09:52 AM

1. First, after opening the interface, click the file menu in the upper left corner. 2. Then, click the settings button in the preferences column. 3. Then, in the settings page that jumps, find the update section. 4. Finally, click the mouse to check and enable it. Download and install the new VSCode version button in the background on Windows and restart the program.

How to add files to vscode workspace How to add files to vscode workspace How to add files to vscode workspace How to add files to vscode workspace May 09, 2024 am 09:43 AM

1. First, open the vscode software, click the explorer icon, and find the workspace window 2. Then, click the file menu in the upper left corner and find the add folder to workspace option 3. Finally, find the folder location in the local disk , click the add button

How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode May 09, 2024 am 10:30 AM

1. First, open the settings option in the settings menu. 2. Then, find the terminal column in the commonly used page. 3. Finally, uncheck the usewslprofiles button on the right side of the column.

How to set animation smooth insertion in VScode VScode tutorial to set animation smooth insertion How to set animation smooth insertion in VScode VScode tutorial to set animation smooth insertion May 09, 2024 am 09:49 AM

1. First, after opening the interface, click the workspace interface 2. Then, in the open editing panel, click the File menu 3. Then, click the Settings button under the Preferences column 4. Finally, click the mouse to check the CursorSmoothCaretAnimation button and save Just set it

How to open workspace trust permissions in Vscode Vscode method to open workspace trust permissions How to open workspace trust permissions in Vscode Vscode method to open workspace trust permissions May 09, 2024 am 10:34 AM

1. First, after opening the editing window, click the configuration icon in the lower left corner 2. Then, click the Manage Workspace Trust button in the submenu that opens 3. Then, find the page in the editing window 4. Finally, according to your office Just check the relevant instructions if required

How to open animation in Vscode Introduction to the method of opening animation in Vscode How to open animation in Vscode Introduction to the method of opening animation in Vscode May 09, 2024 am 10:28 AM

1. First, click to open the settings option in the More menu. 2. Then, find the terminal column under the Features section. 3. Finally, on the right side of the column, click the enableanimation button with the mouse and save the settings.

See all articles