开始
下载安装
官方网站:官方网站
Maven镜像仓库:mvnrepository
配置使用
一般解压到D:\apache-maven-3.6.3这个目录,然后需要配置D:\apache-maven-3.6.3\conf\settings.xmlsettings.xml文件中有所有的可配置信息(被注释掉了),找到对应的位置进行配置。
配置JDK版本,maven中默认使用的jdk1.5。
<profiles><!-- 在已有的profiles标签中添加profile标签 --><profile><id>myjdk</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties></profile></profiles><!-- 让增加的 profile生效 --><activeProfiles><activeProfile>myjdk</activeProfile></activeProfiles>
配置镜像地址为阿里云
<!--setting.xml中添加如下配置--><mirrors><mirror><id>aliyun</id><!-- 中心仓库的 mirror(镜像) --><mirrorOf>central</mirrorOf><name>Nexus aliyun</name><!-- aliyun仓库地址 以后所有要指向中心仓库的请求,都会指向aliyun仓库--><url>http://maven.aliyun.com/nexus/content/groups/public</url></mirror></mirrors>
配置本地仓库位置
<!--找到对应位置--><localRepository>D:\repository</localRepository>
在IDEA中使用File | Settings | Build, Execution, Deployment | Build Tools | Maven
找到上面的路径,
项目结构
- projectNane
- src
- main:存放项目使用的Java代码及相关静态文件
- java:存放Java代码
- resources:存放静态资源文件
- test:放测试用的代码及文件
- java
- resources
- main:存放项目使用的Java代码及相关静态文件
- pom.xml:Maven的配置文件(重要)
依赖导入
<dependencies><!--在下面加依赖--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency></dependencies>
小结
以上是简单的Maven使用说明,学习完后可以写最基本的项目。Maven指令
- src
