参考文章
https://blog.csdn.net/qq_30062385/article/details/130519223
https://blog.csdn.net/qq_21359547/article/details/79731665
1. ORACLE connection driver
1. Check that there is a driver in the ORACLE DATABASE you downloaded
Corresponding to the driver of this version of the database
2. Find the current Oracle version (it will be used later to execute the maven command). Execute the "select * from v$version" SQL statement to query the version.
3. Copy the jar package just now to an empty folder
The folder name is arbitrary, and then create a pom.xml file
pom.xml file content:
pom文件需要指定以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>xxx</artifactId>
<groupId>xxx</groupId>
<version>xxx</version>
</project>
The three parameters inside correspond to the parameters of the maven statement to be executed
4. Execute the maven command.
Enter the folder, open cmd and execute the following command
maven安装jar包命令:
mvn install:install-file -Dfile=ojdbc6.jar -Dpackaging=jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0
Command explanation: mvn install:install-file -Dfile="absolute path of jar package" -Dpackaging="file packaging method" -DgroupId=groupid name -DartifactId=artifactId name -Dversion=jar version (artifactId name corresponds to maven configuration later dependency name).
The three parameters correspond to the content that should be filled in the above pom file
BUILD SUCCESS will appear after the installation is successful
You can see it in your own maven warehouse
5. Import dependencies into the project
In the project pom.xml import dependencies, you can use
<!-- 本地oracle驱动 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.1.0</version>
</dependency>
If the import is really unsuccessful, you can look at the end, some driver replacements.
Two, Exception in thread “main” java.lang.UnsupportedClassVersionError solution
Two situations:
1. JDK, JRE version is too low, not suitable for the existing maven, so mvn install will report an error
2. Compilation and running version does not match, java version and javac version are inconsistent
first solution
Re-install the next JDK, the version must be greater than or equal to the current JDK adapted by maven
Second solution
Open the environment variable, reconfigure, and ensure that the final
version is consistent. The version here is 1.6 for its own reasons (for reference only), but I used 1.8 when compiling maven
Check the configuration of these places
注意,如果不行可以试着吧path中的java环境变量往上移
3. Install the local oracle jar package to the maven warehouse and report a NullPointerException solution
The error is reported as shown in the figure below.
It is precisely because there is no pom file that the above error occurs.
Write the content of the pom file according to the above, and then execute the mvn command to succeed.
4. Some methods to replace the local ORACLE jar package
com.oracle.database.jdbc
<!-- oracle连接驱动 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
com.oracle.ojdbc
<!-- 解决不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK -->
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
<version>19.7.0.0</version>
</dependency>
<!--Oracle 连接组件-->
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
This requires the introduction of a parent dependency
<parent>
<artifactId>spring-boot-dependencies</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.12.RELEASE</version>
</parent>
The above drivers have only been tested briefly, and I cannot guarantee that they are completely reliable. It is recommended to replace them first. Finally, it is recommended to use the one that comes with you after downloading the database.
`One of the problems mentioned above was encountered during the installation process. I would like to share it with you. I hope it will be useful to everyone. There are thousands of problems. If it is not the above problem, I suggest you look it up yourself``