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.
To Maven Project, there's a pom.xml
for you to add dependencies, which is equal to add referenced libraries in non-tools project.
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.
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,
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
Add related dependency to pom.xml
:
<dependency>
<groupId>com.example</groupId>
<artifactId>people</artifactId>
<version>1.0.0</version>
</dependency>
Check it in Maven Dependencies.
Detailed information please view Apache Maven Install usage.