文章徹底轉載自 : http://www.javashuo.com/article/p-fpgrbyif-mx.htmljava
問題一:web
常常遇到公司私服或者中央倉庫沒有的jar包,而後經過各類渠道找到了解決問題的jar包,可是發現沒有pom文件,maven項目引入以後,還有maven在本地倉庫找不到對應jar包的pom文件,打包的時候會在私服下載對應jar包的pom文件而拋出異常,經過maven就能夠解決這個問題。前提是你安裝了maven,而後在命令行執行命令就OK了!!!spring
[ERROR] Failed to execute goal on project AccountEJob: Could not resolve dependencies for project AccountEJob:AccountEJob:jar:1.1.1: Failed to collect dependencies at org.apache.hive:hive-jdbc:jar:1.2.1000.2.6.1.0-129: Failed to read artifact descriptor for org.apache.hive:hive-jdbc:jar:1.2.1000.2.6.1.0-129: Could not transfer artifact org.apache.hive:hive-jdbc:pom:1.2.1000.2.6.1.0-129 from/to nexus (http://XXX.XXX.XXX.XXX:8081/nexus/content/groups/public): Connect to XXX.XXX.XXX.XXX:8081/ [/XXX.XXX.XXX.XXX:8081/] failed: Connection timed out: connect -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
命令:apache
mvn install:install-file -DgroupId=novaplanet.net -DartifactId=commons-lang -Dversion=2.5 -Dfile=F:/commons-lang-2.5.jar -Dpackaging=jar -DgeneratePom=true
DgroupId:是項目組織惟一的標識符,本身隨便起名
DartifactId:項目的惟一的標識符,本身能夠隨便起
Dversion:項目版本
Dfile:jar包路徑(絕對路徑)
DgeneratePom:是否生成pom文件,ture:生成,false:不生成maven
執行成功,會在本地的maven jar包目錄下如下結果
spring-boot
問題二:ui
本身本地的jar包,公司私服上沒有,引入本地的jar包,如今項目的resource目錄下新建lib文件夾,而後將你本地的jar包copy到裏面spa
在maven的配置以下:.net
<dependencies> <dependency> <groupId>novaplanet.net</groupId> <artifactId>javapns-jdk16-163</artifactId> <version>1.2</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/javapns-jdk16-163-1.2.jar</systemPath> </dependency> </dependencies>
build插入下面配置:命令行
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
個人實例配置:
<?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> <groupId>com.teset</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>demo</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>novaplanet.net</groupId> <artifactId>bcprov-jdk16-145</artifactId> <version>1.2</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/bcprov-jdk16-145-1.2.jar</systemPath> </dependency> <dependency> <groupId>novaplanet.net</groupId> <artifactId>commons-lang</artifactId> <version>2.5</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/commons-lang-2.5.jar</systemPath> </dependency> <dependency> <groupId>novaplanet.net</groupId> <artifactId>javapns-jdk16-163</artifactId> <version>1.2</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/javapns-jdk16-163-1.2.jar</systemPath> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> </build> </project>
引入以後,編譯項目,編譯成功不必定引入成功了,接着打包,看jar包中的classes下的lib中有沒有你須要引入的jar包