Maven manually adds the orcale11 driver package to the jar local repository



Zero. Introduction:

This article takes adding oracle11 driver package jar as an example.

(Personally lazy, like bat files, extract public code as tool)

If you want the simplest, please see (1 3) (3 1)

One code implementation

(the following uses Notepad to write the configuration file, modify the text suffix)

1 config.ini

Purpose: used to configure jar package information

Note : 1) The path with a / slash path is the corresponding jar path in the orcale11 installation address

2) The following parameters are related to the maven pox.xml reference



[Common]

Dfile=D:/oraclexe/app/ oracle/app/oracle/product/11.2.0/server/jdbc/lib/ojdbc6.jar 

DgroupId=com.oracle

DartifactId=ojdbc6

Dversion=11.2.0

Dpackaging=jar``

2 readconfig.bat

Purpose: read configuration file information The tool class

format : call readconfig ab (a is the variable of the key, and b is the variable of the value)



CALL :readconfig %1 %2

:readconfig

  for /f "skip=1 tokens=1,2 delims==" %%a IN (config.ini) Do if %1==%%a set %2=%%b

goto :eof

3 manually add local Warehouse.bat (batch file, name is optional)

Purpose: Read the configuration file with one click, and add jar to the maven local warehouse

Prerequisite : Configure maven environment variables or cd into the maven installation directory bin

Key command: Set the specified file type to packaging file, import maven local warehouse and set groupId, artifactId, version for use.



mvn install:install-file -Dfile=xxx -DgroupId=xxx -DartifactId=xxx -Dversion=xxx -Dpackaging=xxx



bat content is as follows



@echo off

CALL readconfig Dfile Dfile --file location

CALL readconfig DgroupId DgroupId --category

CALL readconfig DartifactId DartifactId --name

CALL readconfig Dversion Dversion --version

CALL readconfig Dpackaging Dpackaging --package type

mvn install:install-file -Dfile=%Dfile% -DgroupId=%DgroupId% -DartifactId=%DartifactId% -Dversion=%Dversion% -Dpackaging=%Dpackaging%

pause;

2. Effect

1 File list

 

2 Use screenshots and

double-click to add manually Go to the local warehouse.bat (flashback after running, normal).

 

3. Use

1 pox.xml to add dependencies



 

 

       

 

    com.oracle

  

    ojdbc6

  

    11.2.0

   

2 maven project rebuild, or copy the native jar directly to:

mavan specified warehouse address + path

Note: path=groupId.artifactId.version path schema



F:\Mysoft\maven\apache-maven-3.5.2-bin\maven_repository\com\oracle\ojdbc6\11.2.0\ojdbc6.jar

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326418236&siteId=291194637