3

I have created spring-boot project in VS Code with maven. I am going to use oracle.jdbc.driver.OracleDriver to connect to oracle database. In Intellij Idea, with right click on the jar I used to click add as library and it was done.

In visual studio code I have added path to ojdbc8.jar in .classpath as shown in this github issue, But I get Caused by: java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver again.

enter image description here

D F
  • 73
  • 1
  • 6
  • 1
    [add local jar files to maven project](https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project) - this might help – venkat Dec 10 '18 at 07:15
  • @venkat, it helped me. it means that pom.xml should be modified too.. – D F Dec 10 '18 at 07:22
  • 1
    @D F - Yes, in a maven project all the dependencies are handled by pom.xml, we can use either the maven repositories to download the dependencies or add it from an external folder. If my comments helped you, can you please up vote it? – venkat Dec 10 '18 at 07:27
  • You can also write an answer and I will mark it as correct one... – D F Dec 10 '18 at 07:30
  • Posted the answer – venkat Dec 10 '18 at 07:38
  • @venkat, I used the second answer in the linked post but this work too.. – D F Dec 10 '18 at 07:39
  • Both should work and thanks- @D F – venkat Dec 10 '18 at 07:40

1 Answers1

2

In a maven project, all the dependencies are handled by pom.xml. We can use either maven repositories to download the dependencies or you can add it from your local directory. The following can be done install jar to local maven repository.

 mvn install:install-file \
-Dfile=<path-to-file> \
-DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<packaging> \
-DgeneratePom=true

Reference - http://maven.apache.org/general.html#importing-jars

venkat
  • 442
  • 5
  • 17