1. Target
1) Get familiar with baisc maven config.
2) Integrate maven into eclipse.
2. Basic maven config
1) Download maven from http://maven.apache.org/download.cgi and choose Maven 3.0.5 (Binary zip)
2) Unzip maven.
3) Set environment variables in windows
1) add MAVEN_HOME with value D:\Program Files\apache-maven-3.0.5
2) add PATH with value %MAVEN_HOME%\bin
4) Type mvn -version in CMD to test whether the variables have been set correctly.
3. A glimpse of maven dirs
1) In conf/settings.xml, we can config proxies and repository for maven. This config file is global scope config.
2) The default location for maven respository is C:/Users/Administrator/.m2/repository.
2) C:/Users/Administrator/.m2/settings.xml is user scope config. <We need to copy golbal setting.xml to this folder as this file doesn't exists at start up>
4. A simple example using maven without IDE
1) First we create a folder: D:/workspace/maven as the root folder for our project.
2) In the folder maven, we create a simple pom.xml
<?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> <groupId>edu.xmu.maven</groupId> <artifactId>MavenExample-ModuleOn</artifactId> <packaging>jar</packaging> <version>0.0.1-SNAPSHOT</version> </project>
1) groupId---> Means the project name.
2) artifactId ---> Means a single module inside the project.
3) packaging ---> jar/war
4) modelVersion ---> Must be set as 4.0.0
5) version ---> SNAPSHOT means not RELEASE version. May be changed quite often.
3) In the folder D:/workspace/maven/src/main/java, we manually create a dir edu/xmu/maven
4) In the path D:\workspace\maven\src\main\java\edu\xmu\maven we create a Test.java file
package edu.xmu.maven; public class Test { public void sayHello(String name) { System.out.println("Hello, " + name); } }
5) In CMD, type command as below
1) We have to make sure the proxy is configured correctly in settings.xml ----> Use ping repo1.maven.org to validate if we can connect to main respository.
2) We have to make sure the JAVA_HOME is configured as jdk main folder and not as jre main folder ---> Or else, build failure occurs.
6) Inspect the compile output folder: D:\workspace\maven\target\classes
7) The destination .class file is generated as D:\workspace\maven\target\classes\edu\xmu\maven\Test.class
5. A glimpse of installed directory hierarchy after we type mvn install in CMD
1) The .jar is released as C:\Users\Administrator\.m2\repository\edu\xmu\maven\MavenExample-ModuleOne\0.0.1-SNAPSHOT\MavenExample-ModuleOne-0.0.1-SNAPSHOT.jar
2) The C:\Users\Administrator\.m2\repository is the default position we publish/install our project.
3) The \edu\xmu\maven\MavenExample-ModuleOne\0.0.1-SNAPSHOT means groupId + artifactId + version <different groupId means different project, diffetent artifactId means different module in one project>
4) The MavenExample-ModuleOne-0.0.1-SNAPSHOT.jar means artifactId + version.
6. A simple introduction of maven dir
7. A simple introducition of maven command
mvn archetype:create :Create Maven project
mvn compile :Compile source code
mvn test-compile :Compile test source code
mvn test : Run unit test
mvn site : Generate related sites
mvn clean :Clean generated target folder
mvn package : Generate .jar file
mvn install :Install .jar/.war into local maven Repository
mvn deploy:Deploy .jar/.war into remote repository
mvn eclipse:eclipse :Generate eclipse project file
相关推荐
.TEMP_IMG1682649910810 使用jianguoyun的手机md编辑器
Maven更新问题 今天Maven在更新的时候发现一直更新不成功,总结下解决方法。 在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven ...
idea创建Maven项目时,报错显示Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources,并且Maven插件内看不到 mybatis-generator。如下图: 折腾了好久发现配置放错地方了,...
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
Over 90 hands-on recipes to successfully build and automate development life cycle tasks following Maven conventions and best practices About This Book Understand the features of Apache Maven that ...
**Maven教程:基础篇——尚硅谷学习笔记 2022年** Maven是一个强大的Java项目管理和构建工具,由Apache软件基金会开发。它通过提供一个标准的项目对象模型(Project Object Model,POM)来简化项目的构建过程,并...
3. **构建生命周期**:Maven定义了一套标准的构建生命周期,包括清理、默认和站点三个阶段。每个阶段有多个阶段(如编译、测试、打包),开发者可以自定义这些阶段的行为。 4. **多模块项目**:Maven支持大型项目的...
Maven 3.5.4版本是在Maven 3.x系列中的一个稳定版本,它带来了一些重要的改进和修复。例如,提升了依赖解析的性能,优化了本地仓库的索引处理,以及对远程仓库的访问策略有所调整。此外,这个版本还增强了对Java 9和...
在IT行业中,构建工具起着至关重要的作用,它们帮助开发者管理项目依赖,自动化构建过程,使得软件开发...同时,了解如何使用Maven与IDE(如Eclipse)集成,以及如何管理项目依赖,这些都是提升开发效率的重要技能。
maven-install-plugin-2.4.jar
如果在执行此过程时,IDE找不到合适的Java运行环境(JRE或JDK),或者Maven配置存在问题,就可能导致“Unable to import Maven project”的错误。在描述中提到,错误日志显示JDK版本为11,这可能是一个触发问题的...
在<plugins></plugins>中添加 <groupId>org.apache.maven.plugins <artifactId>maven-compiler-plugin <version>3.8.1 <source>1.8 <target>1.8 </plugin>
** MAVEN 安装与配置详解 ** Apache Maven 是一个强大的项目管理工具,它基于项目对象模型(Project Object Model,POM),通过插件和坐标概念来简化Java项目的构建、依赖管理和文档生成。Maven 3.0.5是其历史版本...
赠送Maven依赖信息文件:config-1.2.1.pom; 包含翻译后的API文档:config-1.2.1-javadoc-API文档-中文(简体)版.zip; Maven坐标:com.typesafe:config:1.2.1; 标签:typesafe、config、中文文档、jar包、java; ...
maven打包,指定入口类的jar包,具体的pom配置为: <groupId>org.apache.maven.plugins <artifactId>maven-shade-plugin <version>3.1.0 <phase>package <goal>shade implementation="org....
3. **构建生命周期管理**:Maven定义了一系列的构建生命周期阶段(如`clean`、`compile`、`test`、`package`、`install`、`deploy`等),开发者可以通过命令行工具执行这些阶段,自动化构建流程。 4. **插件和目标*...
**eclipse-maven3-plugin** 是一个专门为 Eclipse IDE 设计的插件,它允许开发者在 Eclipse 开发环境中无缝集成 Maven 构建工具。Maven 是一个项目管理和综合工具,广泛用于 Java 应用程序的构建、依赖管理和项目...
3. **compile**:执行Default生命周期中的`compile`阶段,调用`maven-compiler-plugin`的`compile`目标来编译源代码。 4. **test**:执行Default生命周期中的`test`阶段,调用`maven-surefire-plugin`的`test`目标来...
"maven3.x几个版本免安包.rar" 提供了Maven 3.x的多个版本,无需安装即可使用,这对于开发者在不同环境中快速配置或测试Maven环境非常方便。 1. Maven简介: Maven 是Apache软件基金会的一个项目,由Jason van Zyl...