framwork maven的配置及使用
maven的配置及使用
一.什么是maven:
参考百度百科:
http://baike.baidu.com/link?url=Kdew1Be1-rDr08gp2ulNCae2aTB1L1HGP5GLJ4vGR6s4POL3YvAtI4Wz870Wc_l79tkxZc5kcwXG9kPQyq3-__
二.创建maven项目:
1.创建Maven Project:

2.勾选Create a simple project:

3.maven setting:
groupId: 相当于这个project的所有者或者机构的一个标识,一般是com.company.xxx这种格式
artifactId: 这个project最后所生成的文档(jar、war)的名字,比如对于junit这个开源的project,它的artifactId就是junit
packaging: 这个project的打包的类型,一般是war、jar等值
version: project的版本
name: project的名字,生成文档等内容的时候会用的这个名字

4.创建后maven项目的目录结构:

三.配置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.zlp</groupId>
<artifactId>mavenTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenTest</name>
<description>test</description>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
maven配置就是修改pom.xml文件,在<dependencies>放如下代码</dependencies>增加如下配置:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.0.0.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
注意:如果不存在<dependencies>自己写个,位置在</project>上面就行!
这只是一个,可以放多个。spring、spring mvc 、junit等等。会自动下载所需要的包及相关文件,在本机的这个位置:user下面的用户下面的.m2文件夹下的repository。不知道user在哪里,你也可以直接搜这个文件夹。下载有时会失败,那么只能用笨方法,从别人哪里拷贝,放到下载所在的文件夹中。
配置完后如下:
pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zlp</groupId>
<artifactId>mavenTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenTest</name>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>C:\work\mavenTest\src\main\java</sourceDirectory>
<scriptSourceDirectory>C:\work\mavenTest\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>C:\work\mavenTest\src\test\java</testSourceDirectory>
<outputDirectory>C:\work\mavenTest\target\classes</outputDirectory>
<testOutputDirectory>C:\work\mavenTest\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>C:\work\mavenTest\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\work\mavenTest\src\test\resources</directory>
</testResource>
</testResources>
<directory>C:\work\mavenTest\target</directory>
<finalName>mavenTest-0.0.1-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
</executions>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>C:\work\mavenTest\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>C:\work\mavenTest\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>C:\work\mavenTest\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>C:\work\mavenTest\target\site</outputDirectory>
</reporting>
</project>
四.maven创库及查找方式:
1.仓库地址:http://mvnrepository.com
2.查找方式:
下面以servlet为例:
打开创库地址:
搜素需要的包:

如下图,会搜素到多个版本,自己选择把,然后点击 servlet-api

拷贝maven下的内容:

成功找方法,失败找借口。
---------心态
framwork maven的配置及使用的更多相关文章
- 国内可用maven repository 配置
国内可用maven repository 配置 发表于2016/1/4 23:08:04 10235人阅读 分类: maven 鉴于一些原因,从maven中央仓库download依赖包时,被各种折磨 ...
- MyEclipse中Maven的配置
之前在MyEclipse这个IDE中配置Maven,完成配置后启动Maven时出现-Dmaven.multiModuleProjectDirectory system propery is not s ...
- maven的安装,maven库配置和Eclipse插件的安装
maven的安装,maven库配置和Eclipse插件的安装 1.下载并解压maven 2.配置环境变量 3.配置maven配置文件 1.下载链接 Downloading Apache Maven 2 ...
- Eclipse下Maven插件配置
要做一个基于C/S架构的汽车租赁系统,由于在实习期间接触过一些Java和SpringMVC,Spring,Hibernate的东西,所以决定使用这个框架组合来完成这个项目. 首先是Maven的配置,为 ...
- maven打包配置
maven打包配置,到底要打包哪些文件,如何配置?? <build> <finalName>weatherAdminSys</finalName> <plug ...
- 开发流程和Maven的配置
按照何种开发模型? V模型:项目需求--->概要设计(功能模块) --->详细设计(页面的设计,数据库的设计) --->编码(框架的搭建,功能的实现)---->测试(单元测试, ...
- Eclipse中Maven的配置
Maven 的配置 1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven 1.2 配置 Maven 的c ...
- 【maven教程】(1)---maven环境配置
maven环境配置 刚开始学习maven,现在项目需要用到maven,而且他确实很好用,也比较容易上手,我也是主要通过视频学习,在写博客的时候也会总结其它人所写 博客,从简到难,如果你也是初学者那接下 ...
- Eclipse上Maven环境配置使用 (全)
Eclipse上Maven环境配置使用 (全) 1. 安装配置Maven: 1.1 从Apache网站 http://maven.apache.org/ 下载并且解压缩安装Apache Maven. ...
随机推荐
- Kerberos的hive链接问题
javax.security.auth.login.LoginException: Checksum failed 之前碰到过类似的问题,都是因为服务器端的keytab问题:多半是因为重新生成了key ...
- 异常java.sql.SQLException: Field 'id' doesn't have a default value
使用spring data jpa出现这个情况. entity中的自增策略已经加好了. 还是出现这个异常.去数据库中查看,发现没有给主键加上自增. 出现这个问题去实体类跟数据库中看一下就可以了.
- Angular5学习笔记 - 创建、运行、发布项目(一)
一.安装脚手架 npm install -g cnpm --registry=https://registry.npm.taobao.org #安装阿里镜像 npm install -g @angul ...
- POJ1063Cable master(二分搜索)
Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36288 Accepted: 7743 Des ...
- Spring Boot发布和调用RESTful web service
Spring Boot可以非常简单的发布和调用RESTful web service,下面参考官方指导体验一下 1.首先访问 http://start.spring.io/ 生成Spring Boot ...
- SQL字符串拼接
不同的数据库,相应的字符串拼接方式不同,通过对比加深一下记忆. 一.MySQL字符串拼接 1.CONCAT函数 语法格式:CONCAT(char c1, char c2, ..., char cn) ...
- java代码实现通讯录实例,我不知道这有什么用。,
运行显示: Friend:zl,Address:武大樱花美Colleagues:蔡依林,Department:麻城市人民政府 题目: 1.任务描述 完善上面通讯录名片的例子. 2.技能要点 掌握类继承 ...
- c# 窗口API,以及全屏锁定一些tips
this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; /* FormBo ...
- kvm iptables 3306端口
# iptables -t nat -A PREROUTING -p TCP --dport 3306 -j DNAT --to-destination 192.168.122.102:3306# i ...
- Django的Model使用
创建模型 使用Django的模型主要注意两个方面:字段的类型和方法的重写.这里用一个例子来说明,其中包含了常用的字段类型和如何重写方法. from django.db import models cl ...