用途:用于项目构建 jar包下载管理
maven配置
- setting文件 地址 maven\apache-maven-3.6.3\conf\settings.xml
常用配置解释:
本地仓库地址
1
| <localRepository>D:\maven</localRepository>
|
访问仓库的用户密码
1 2 3 4 5
| <server> <id>ID</id> <username>admin</username> <password>1234</password> </server>
|
镜像仓库地址 作用类似于代理,若中央远程仓库在国外,可以使用此处配置国内的镜像仓库
1 2 3 4 5 6
| <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>
|
远程仓库 本地依赖的下载来源仓库
1 2 3 4 5 6 7 8 9 10
| <repository> <id>aliyun-repos</id> <url>https://maven.aliyun.com/repository/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository>
|
若不在settings.xml配置,则默认在 C:\Users\Administrator\.m2 里面(Administrator为目前windows的用户名)
File—>settings—>Buile,Execution,Deployment—>maven 配置
Maven home directory 配置 本地maven安装目录
User settings file 配置 settings.xml文件地址
Local repository 配置 本地maben仓库地址
pom配置
spring项目在创建时会创建一个pom.xml文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| <?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>
<parent> <artifactId>nacos</artifactId> <groupId>com.simplemw</groupId> <version>1.0-SNAPSHOT</version> </parent>
<artifactId>nacos-config</artifactId>
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
<profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> </properties> </profile> <profile> <id>pre</id> <properties> </properties> </profile> </profiles> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.6.RELEASE</version> <scope>compile</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>UTF-8</encoding> <compilerArgs> <arg>-parameters</arg> </compilerArgs> </configuration> </plugin> </plugins> </build>
</project>
|
注:依赖的scope五种设置 compile、provided、runtime、test、system
compile:scope的默认配置,编译以及测试运行时都提供,打包会包含进去
provided:只在使用的时候(并且JDK或者容器中已经存在该资源),编译以及测试运行时才提供,打包不会包含进去
runtime:不进行编译,测试和运行时提供,打包不会包含进去
test:不进行编译,只在测试时使用
system:用于指定本地jar时使用