0

My Team and myself working on a spring boot application. Rest of my team is using Intellij Idea, but I am using VS code. The problem is I need to add external jars into my project but I didn't find any option in vscode. The spring boot project is based on maven. I googled and find many people suggesting the option of 'referenced library' to add external jars, But In my case, this option is not there. I have almost every extension installed on my vs code.

My colleagues are able to add these external jars in IntelliJ Idea through -> right-click on jars -> add as library. Is there any option available in case of vs code too.

I also tried to modify the .classpath but it's surprising that the .classpath file is in the project but not visible in the project explorer.

Please suggest what is the way to add external jars as a dependency in a spring boot maven project in vs code.

enter image description here

2
  • is there any restriction that prevents you from using intellij? because for java and kotlin intellij has far superiors features for them 🙂 Commented Jul 14, 2021 at 10:50
  • No, there is no such restriction. But I use vs code for most of the things. And rest of the things are working fine in vs code but stuck on this thing :) Commented Jul 14, 2021 at 10:54

1 Answer 1

4

To Maven Project, there's a pom.xml for you to add dependencies, which is equal to add referenced libraries in non-tools project.

  1. You can search your needed jars from Maven Repository and copy its dependency description in Maven, then add it to pom.xml. For example, mysql-connector-java-8.0.25.

  2. Open Command Palette and search Maven: Add a dependency, you can search in VS Code and choose the one you needed, which reflects to pom.xml is also adding dependencies. Reference: Maven in VSCode

[UPDATE]

About how to use customized jar in maven project,

  1. Install the needed jars to local repository, take people.jar as example:

     mvn install:install-file -Dfile=path\to\people.jar '-DgroupId=com.example' -DartifactId=people '-Dversion=1.0.0' -Dpackaging=jar 
    
  2. Add related dependency to pom.xml:

     <dependency>
         <groupId>com.example</groupId>
         <artifactId>people</artifactId>
         <version>1.0.0</version>
     </dependency>
    
  3. Check it in Maven Dependencies.

enter image description here

Detailed information please view Apache Maven Install usage.

Sign up to request clarification or add additional context in comments.

3 Comments

The problem is the dependency is not available in the maven repository. These are the jars developed by our team. I need to add those jars in the project.
@BabitaBisht. I've update my answer, have a try.
Wang-MSMT thanks :) It solved the issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.