本文主要包括:
- Maven杂记
Maven配置cloudera源下载CDH依赖包
由于Cloudera Manager自动安装部署的Hadoop、Hbase,Zookeeper等组件与Apache提供的会有差异,所以需要配置为对应CDH版本的依赖包。
添加cloudera仓库
在pom.xml,project标签内开头添加如下仓库:
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
不需要在settings.xml里添加
jar 命令行方式上传至私服
- settings 配置文件中添加账密
<servers> <server> <id>deploymentRepo</id> <username>dwplatform</username> <password>a398K4py</password> </server> </servers>
- 命令行执行如下命令
maven 插件版本 :"maven-deploy-plugin:2.7" mvn deploy:deploy-file -DgroupId=com.cloudera -DartifactId=ImpalaJDBC41 -Dversion=2.6.3 -Dpackaging=jar -Dfile=C:\Users\digiwin\Desktop\数据服务\ImpalaJDBC41-2.6.3.jar -Durl=https://repo.digiwincloud.com.cn/maven/repository/releases/ -DrepositoryId=deploymentRepo #去除换行符: mvn deploy:deploy-file -DgroupId=com.cloudera -DartifactId=ImpalaJDBC41 -Dversion=2.6.3 -Dpackaging=jar -Dfile=C:\Users\digiwin\Desktop\数据服务\ImpalaJDBC41-2.6.3.jar -Durl=https://repo.digiwincloud.com.cn/maven/repository/releases/ -DrepositoryId=deploymentRepo
- pom 文件中配置私有仓库坐标
<repositories> <repository> <id>deploymentRepo</id> <name>deploymentRepo</name> <url>https://repo.digiwincloud.com.cn/maven/repository/releases/</url> </repository> </repositories>
- 引入依赖
<dependency> <groupId>com.cloudera</groupId> <artifactId>ImpalaJDBC41</artifactId> </dependency>
maven项目引用本地jar包
<dependency>
<groupId>com.cloudera</groupId>
<artifactId>ImpalaJDBC41</artifactId>
<version>2.6.3</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ImpalaJDBC41-2.6.3.jar</systemPath>
</dependency>
<!-- 在build里的resources里添加如下内容-->
<resources>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
然后打包mvn clean package
,jar包里就有lib下的jar了
设置阿里云镜像
在网上找了各种文件都不行,这个是实测可行的
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/Users/gujincheng/.m2/repository</localRepository>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>central</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>central repo</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>apache snapshots</mirrorOf>
<name>apache</name>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</mirror>
</mirrors>
<proxies/>
<activeProfiles/>
<profiles>
<profile>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>aliyunmaven</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>MavenCentral</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>aliyunmavenApache</id>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
具体可以参考[IDEA Maven 源修改为国内阿里云镜像的正确方式][1]
[1]: https://developer.aliyun.com/article/1328237