本地仓库 :它是个人电脑上的资源库,可以从私服和中央仓库
获取资源
远程仓库
1.私服:公司自己建立的仓库,可以从中央仓库获取资源
2.中央仓库:maven开发团队维护的仓库
在 maven-web 工程中的pom.xml中使用scop标签进行规定依赖范围。
测试总结:
默认引入 的 jar 包 ------- compile 【默认范围 可以不写】(编译、测试、运行 都有效 )
servlet-api 、jsp-api ------- provided (编译、测试 有效, 运行时无效 防止和 tomcat 下 jar 冲突)
jdbc 驱动 jar 包 ---- runtime (测试、运行 有效 )
junit ----- test (测试有效)
依赖范围由强到弱的顺序是:compile>provided>runtime>test
打包形式为
<packaging>pom</packaging>在子工程中声明其父工程坐标与对应的位置
<!--定义该工程的父工程--> <parent> <groupId>com.itheima</groupId> <artifactId>ssm</artifactId> <version>1.0-SNAPSHOT</version> <!--填写父工程的pom文件--> <relativePath>../ssm/pom.xml</relativePath> </parent>在父工程中定义依赖管理
<!--声明此处进行依赖管理,必须添加--> <dependencyManagement> <!--具体的依赖--> <dependencies> <!--spring环境--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.1.9.RELEASE</version> </dependency> <dependencies> <dependencyManagement>在子工程中定义依赖关系,无需声明依赖版本,版本参照父工程中依赖的版本
<dependencies> <!--spring环境--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> </dependencies>Nexus是Sonatype公司的一款maven私服产品
下载地址:https://help.sonatype.com/repomanager3/download
启动服务器(命令行启动)
nexus.exe /run nexus访问服务器(默认端口:8081)
http://localhost:8081修改基础配置信息
安装路径下etc目录中nexus-default.properties文件保存有nexus基础配置信息,例如默认访问端口修改服务器运行配置信息
安装路径下bin目录中nexus.vmoptions文件保存有nexus服务器启动对应的配置信息,例如默认占用内存空间配置本地仓库访问私服的权限(setting.xml)
<servers> <server> <id>boke-release</id> <username>admin</username> <password>admin</password> </server> <server> <id>boke-snapshots</id> <username>admin</username> <password>admin</password> </server> </servers>配置本地仓库资源来源(setting.xml)
<mirrors> <mirror> <id>nexus-boke</id> <mirrorOf>*</mirrorOf> <url>http://localhost:8081/repository/maven-public/</url> </mirror> </mirrors>配置当前项目访问私服上传资源的保存位置(pom.xml)
<distributionManagement> <repository> <id>boke-release</id> <url>http://localhost:8081/repository/heima-release/</url> </repository> <snapshotRepository> <id>heima-snapshots</id> <url>http://localhost:8081/repository/heima-snapshots/</url> </snapshotRepository> </distributionManagement>发布资源到私服命令
mvn deploy heima-snapshots http://localhost:8081/repository/heima-snapshots/ ```发布资源到私服命令
mvn deploy