4 Maven
Maven:自动导入和配置jar包
Maven项目架构管理工具
Maven规定如何去编写Java代码,安装规范
Maven下载,配置
-
Maven官网下载:apache-maven-3.8.2-bin.zip
-
配置系统变量:
变量名:M2_HOME 变量值:D:\professional software\environment\apache-maven-3.8.2\bin
变量名:MAVEN_HOME 变量值:D:\professional software\environment\apache-maven-3.8.2 -
在用户变量的path变量中添加变量%MAVEN_HOME%\bin
-
在管理员命令提示符下,输入mvn -version正常显示版本即成功配置
国内如何加快Maven的下载jar包的速度?
阿里云镜像
在maven的conf下找到setting.xml,修改未注释的mirror部分为以下内容
//更改前:
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
//更改后
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
建立仓库
<localRepository>/path/to/local/repo</localRepository>
-->
//在上面代码下加入下面这一行,地址为自定义创建的仓库地址,也可用默认的
<localRepository>D:\professional software\environment\apache-maven-3.8.2\maven-repo</localRepository>
maven由于约定大于配置,导致配置文件无法导出或生效,解决方案:
<!--在build中配置resources,防止资源导出失败问题-->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>