maven 配置

1、部署到tomcat下
mvn tomcat:run


2、mac下安装jdk
配置
sudo vim ~/.bash_profile
--jdk配置
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home

--mvn配置
export M2_HOME=/Users/administrator/app/apache-maven-3.6.1
export PATH=$PATH:$M2_HOME/bin

3、本地仓库
3.1、配置本地仓库
3.2、在工具里配置maven(maven安装路径、配置、本地库)

4、常用命令
clean:删除target
compile:编译出.class文件
test:测试
package:打包到target目录里
install:打包到本地仓库
5、maven三套生命周期
5.1、cleanLifeCycle
clean
5.2、defaultLifeCyle
complie test package install deploy
5.3、siteLifeCyle
site
6、Maven传递依赖了解原理及版本冲突解决
6.1、传递依赖,A-B,B-C,A传递依赖C
6.2、版本冲突解决规则
a.第一声明者优先原则
b.路径近者优先原则(【直接依赖】优先级高于【传递依赖】)
c.排除依赖
<exclusions>
<exclusion>...</exclusion>
</exclusions>
d.版本锁定,dependencyManagement并不导入依赖,只起到指定版本的作用
<dependencyManagement>
</dependencyManagement>
7、父工程的作用
7.1、子模块继承
7.2、管理子模块

8、nexus 私服仓库类型
hosted:宿主仓库
proxy:代理仓库
group:组仓库(包含各种仓库)

9、上传到私服的配置
9.1、maven config\setting.xml配置私服用户名和密码
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>

<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

<server>
<id>public</id>
<username>admin</username>
<password>admin123</password>
</server>

9.2、pom中配置上传地址
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.0.109:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.0.109:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

9.3、deploy上传到私服

10、从私服上下载依赖的配置(maven\config\setting.xml)
10.1、配置获取依赖的地址profile
<profile>
<id>dev</id>
<repositories>
<repository>
<id>public</id>
<url>http://192.168.0.109:8081/repository/maven-public/</url>

<releases>
<enabled>true</enabled>
</releases>

<snapshots>
<enabled>true</enabled>
</snapshots>

</repository>
</repositories>
<pluginRepositories>

<pluginRepository>
<id>public</id>
<name>public</name>
<url>http://192.168.0.109:8081/repository/maven-public/</url>
</pluginRepository>

</pluginRepositories>
</profile>

10.2、激活profile
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>

 

posted @ 2019-07-09 20:12  kuailewangzi1212  阅读(215)  评论(0编辑  收藏  举报