Maven的配置
Maven下载地址 + 环境变量配置
http://maven.apache.org/download.cgi
MAVEN_HOME = D:\apache-maven-3.2.2-bin\apache-maven-3.2.2
PATH += ;%MAVEN_HOME%\bin
mvn -v
如果本地有了maven的本地仓库可以修改为本地仓库,如果不设置本地仓库,系统会自动下载jar包到你的C:/User/User_Name/.m2文件夹下
更改maven的本地仓库的设置方法:
打开Maven的配置文件
D:\apache-maven-3.2.2-bin\apache-maven-3.2.2\conf\setting.xml
其中有这么一段注释,是用来设置本地仓库的:
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> -->
<localRepository>F:\NEXUS_CK</localRepository>
创建Maven项目的时候eclipse和IDEA都会默认一个maven的setting设置,选择maven的setting的配置,不然刚才配置的仓库位置是无效的
Maven在项目中需要一个pom.xml文件来配置所需要的内容和maven插件
pom.xml的大致结构是:
<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>com.againfly</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <!-- 设置版本号或者配置的变量 --> <properties> <spring.version>4.1.4.RELEASE</spring.version> <fastjson.version>1.2.4</fastjson.version> <!--maven plugins --> <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> <maven-compiler-plugin.build.version>1.8</maven-compiler-plugin.build.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- 需要下载的jar包 --> <dependencies> <!-- mysql连接 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.34</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> </dependency> </dependencies> <!-- 设置插件 --> <build> <finalName>demo</finalName> <plugins> <!-- define the project compile level --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <source>${maven-compiler-plugin.build.version}</source> <target>${maven-compiler-plugin.build.version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <!-- Run the JUnit unit tests in an isolated classloader --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.2</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <webXml>src/main/webapp/WEB-INF/web.xml</webXml> </configuration> </plugin> </plugins> </build> <!-- 设定主仓库,按设定顺序进行查找。 --> <repositories> <repository> <id>jeecg</id> <name>jeecg Repository</name> <url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>jeecg-snapshots</id> <name>jeecg-snapshots Repository</name> <url>http://maven.jeecg.org/nexus/content/repositories/snapshots</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>oschina-repos</id> <name>Oschina Releases</name> <url>http://maven.oschina.net/content/groups/public</url> </repository> <repository> <id>java-repos</id> <name>Java Repository</name> <url>http://download.java.net/maven/2/</url> </repository> <repository> <id>springsource-repos</id> <name>SpringSource Repository</name> <url>http://repo.spring.io/release/</url> </repository> <repository> <id>central-repos</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> </repository> <repository> <id>central-repos2</id> <name>Central Repository 2</name> <url>http://repo1.maven.org/maven2/</url> </repository> <repository> <id>local-jar</id> <name>Localhost jar</name> <url>file://${project.basedir}/src/main/webapp/WEB-INF/lib</url> </repository> </repositories> </project>
++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANT下载地址 + 环境变量配置
http://ant.apache.org/bindownload.cgi
ANT_HOME = D:\apache-ant-1.9.4-bin\apache-ant-1.9.4
PATH += ;%ANT_HOME%\bin
ant -version
ant介绍和使用教程:
http://www.cnblogs.com/hoojo/archive/2013/06/14/java_ant_project_target_task_run.html
—— ANT引用自博客园hoojo
最新评论