| Order | 5 |
|---|---|
| Area | java |
| TOCTitle | Project Management |
| ContentId | 251cba68-c77f-4ac6-a5de-1fab8dcca867 |
| PageTitle | Maven Support, Java Package, and Dependency Management in Visual Studio Code |
| DateApproved | 1/2/2019 |
| MetaDescription | Maven Support, Java Package and Dependency Management in Visual Studio Code |
| MetaSocialImage |
This document will give you an overview of how to use the Maven for Java and Java Dependency Viewer extensions to manage your projects within Visual Studio Code.
Maven is a software tool that helps you manage Java projects and automate application builds. The Maven for Java extension for Visual Studio Code provides fully integrated Maven support, allowing you to explore Maven projects, execute Maven commands, and perform the goals of build lifecycle and plugins.
Once a Maven project is loaded, the extension will be activated and it will automatically scan for pom.xml files in your workspace and displays all Maven projects and their modules in the side bar.
The extension provides code snippets and auto completion for adding Maven dependencies based on local Maven repositories. See how easy it is to add a new dependency to your pom.xml with those convenient features.
The extension also enables you to generate effective POM.
By right-clicking each Maven project in the explorer, you can conveniently run Maven goals.
The extension also preserves the history of goals for each project, so you can quickly rerun the previous command, which is useful when you're running a long custom goal.
There are two way to rerun a goal:
- Command Palette > Select Maven: History > Select a project > Select command from the history.
- Right-click a project > Click History > Select command from history.
For each plug-in you use with your project, the extension also provides you an easy way to access the goals within each plugin.
Another handy feature provided by this extension is to generate a Maven project from Archetype. The extension loads archetypes listed in local/remote catalogs. After selection, the extension sends mvn archetype:generate -D... to the terminal.
There are two ways to generate a Maven project:
- From the Command Palette, select Maven: Generate from Maven Archetype.
- Right-click on a folder and select Generate from Maven Archetype.
Visit the GitHub Repo of the Maven extension for additional configurations and a troubleshooting guide.
Project Management in Visual Studio Code is provided by the Java Dependency Viewer extension. This extension has many features including creating projects as well as viewing the package structure of the project and its dependencies.
In addition to creating a project through Maven Archetype, you can also use the following command to create a simple Java project: Command Palette > select Java: Create Java Project.
If you're creating a Spring Boot project, you can also use the Spring Initializr extension, see Spring Boot in Visual Studio Code.
The extension also has a hierarchy view of your project and dependencies, which supplements the file view and outline provided by Visual Studio Code, so you don't need to expand multiple subfolders to just view your Java package.
Read on to find out more about:
- Java Editing - Explore the editing features for Java in VS Code.
- Java Debugging - Find out how to debug your Java project with VS Code.
- Java Testing - Use VS Code for your JUnit and TestNG cases.
- Java Extensions - Learn about more useful Java extensions for VS Code.









