## Preface Because of Oracle It's not open to the public Maven The warehouse provides any Oracle JDBC Driver Of Jar package , So we can't be like MySQL、SQLite When it's so easy to go straight through Maven Load dependencies . And manually download Oracle JDBC Driver Jar package , Then install it to the local warehouse (.m2 Catalog ), And then through Maven Loading dependencies is a common method . But in addition, we can pass `
system
` Way to introduce , But there's going to be a fine line under the pit . ## Manual installation to local warehouse 1. Will ojdbc7-12.1.0.2.jar Placed in the project root lib Under the catalogue , Version management with project ; 2. stay POM.xml Add dependency definitions to the file ; ```
com.oracle
ojdbc7
12.1.0.2
``` 3. Install JAR Package to local warehouse . ``` # Run in the project root mvn install:install-file -Dfile=./lib/ojdbc7-12.1.0.2.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar ``` ## scope For system stay SpringBoot Pit in In addition to the above , We can do it in POM.xml Define dependency as ```
com.oracle
ojdbc7
12.1.0.2
system
${project.basedir}/lib/ojdbc7-12.1.0.2.jar
``` So even if the local warehouse (.m2 Catalog ) There is no Oracle JDBC Driver Rely on , Execute `mvn compile` and `mvn spring-boot:run` Still successfully executed . but ** Please note **, Execute `mvn package` Packaged SpringBoot UberJar The package does not contain Oracle JDBC Driver Rely on , If it is deployed directly to the server, the following error will be reported : > ############ > application failed to start > > Description: > .................................. > Reason: Failed to load driver class oracle.jdbc.driver.OracleDriver in either of HikariConfig class loader or Thread context classloader. > > Action: > Update your application's configuration > ############ The solution : 1. For external connection Web Container of SpringBoot Apply , Will Oracle JDBC Driver Jar The bag is placed in the container lib Under the catalogue ; 2. For built-in Web Container of SpringBoot Apply , Then modify spring-boot-maven-plugin Plug in configuration is enough , See below for details . ## Talk about it Maven Depend on the definition of scope Properties effect : Used to limit dependence on Maven The scope of the project lifecycle . - `compile`, Default value , Dependencies will participate in the compilation phase , And will be packaged until it's finally released ( Such as Jar、War、UberJar) Inside Lib Under the catalogue . It's transitive , That is, the dependency is valid for other projects that depend on the current project ; - `provided`, Dependencies will participate in the compilation phase, but will not be packaged into the final release package , The execution phase consists of a container or JDK Provide . It's not transitive .( Such as Servlet API,JSP API,Lombok etc. ); - `runtime`, Dependencies do not participate in the compilation phase ( That is, not to join classpath), But it will be packed until it's finally released , To participate in the execution and testing phases . Usually used for dynamically loading based on configuration files or interface reflection loading dependencies ( Such as JDBC Drive ); - `test`, Dependency participates in the compilation phase , But don't pack it until it's finally released , Dependencies only participate in the testing phase ; - `system`, Indicates that the path of the dependency is file system based Jar Package path , And it has to go through `systemPath` Specify the local file path . Dependency participates in the compilation phase , The default is not packaged until the final release package . - For Spring Boot Project , If you want to put scope For system Of Jar Package to release package , You need to configure spring-boot-maven-plugin ```
org.springframework.boot
spring-boot-maven-plugin
true
``` - `import`,Maven2.0.9 Newly added scope value . Only in `
` Use in , Dependencies used to reference other projects . - Example ```
io.fsjohnhuang
deps
pom
import
``` - About type pom If the project has a large number of dependencies , That will cause the current project to POM.xml The files are bloated , Even with the father POM Still can't solve the problem well . And through type For pom You can package dependencies into stand-alone projects , Other business system projects can then import related dependencies by introducing them , To simplify POM Archives . - About type Properties Preset type The property value is jar, namely Maven Package the project compilation as Jar package , When set to pom This means that the project is just a packaged definition of a bunch of related dependencies , When set to apk or ejb Waiting time means Maven Use... When compiling and packaging andriod or ejb Related plug-in execution tasks . ## Summary Better a good memory than a bad pen ,Maven Behind the powerful function, there are also a lot of knowledge points , Write it down for future reference ! Please indicate from :https://www.cnblogs.com/fsjohnhuang/p/13937146.html —— \^\_\^ fat