Reputation: 6084
Why does MongoDB maven dependency cannot be added as runtime
whereas for all the other databases it works without any issues ?
pom.xml
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.1.0</version>
</dependency>
Please guide.
Upvotes: 1
Views: 558
Reputation: 19000
Because for oracle you use the jdbc
API which oracle only implement (unless you are using oracle SQL types for example).
You are only using The Connection
, Statement
, ResultSet
and in runtime you obtain an Oracle Connection, probably using a container managed connection pool.
You don't compile your code (again, usually) with classes taken from ojdbc7
jar. The jdbc
interfaces and classes are part of the jre.
Whereas with mongodb, you code and compile with specific classes and interfaces taken from the mongo-java-driver
jar (and jars it depends on). Classes such as MongoClient
, Document
etc.
Upvotes: 3