Maven入门
来源:互联网 发布:linux mysql源码安装 编辑:程序博客网 时间:2024/05/16 12:56
Maven入门
1.为什么需要Maven
2.Maven是什么
Maven, a Yiddish word meaning accumulator of knowledge, was originally started as an attempt to simplify the build processes in the Jakarta Turbine project. There were several projects each with their own Ant build files that were all slightly different and JARs were checked into CVS. We wanted a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information and a way to share JARs across several projects.
The result is a tool that can now be used for building and managing any Java-based project. We hope that we have created something that will make the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.
参考:What is Maven
3.Maven安装及配置
Mac OS可以使用brew进行安装(先安装brew),
$ brew install mavenWindows,
参考:Maven的安装及配置
参考:Linux配置Maven
3.1 配置阿里云的云仓库
1.在<mirrors>元素中加入:
<mirror> <id>aliyun</id> <mirrorOf>centeral</mirrorOf> <name>aliyun mirror</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror>
2.在<profiles>元素中加入:
<profile> <id>aliyun</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile>
4.pom.xml文件的基本介绍
5.基本命令
- mvn archetype:generate 使用模板生成项目
- mvn compile 编译
- mvn test 单元测试
- mvn package 打成war包
- mvn deploy 部署项目
- mvn site 生成项目相关站点,在线文档
- mvn clean 清理操作
- mvn install 将包安装到本地仓库,让其他项目进行依赖
- mvn help:effective-pom 查看继承了父POM之后的POM文件的内容
6.Tomcat插件
- mvn help:describe -Dplugin=tomcat7 详细帮助
- mvn tomcat7:run 启动一个嵌入的Tomcat实例
- mvn tomcat:deploy 部署项目
- mvn tomcat:undeplay 取消部署项目
执行tomcat7插件相关的操作时,提示找不到tomcat7插件?
<pluginGroups> <pluginGroup>org.apache.tomcat.maven</pluginGroup> </pluginGroups>
Tomcat Maven插件配置
软件要求
具体配置
配置tomcat 用户
打开tomcat 安装目录,进入 conf 文件夹下,找到对应的 tomcat-users.xml 文件; 将文件中所有内容删除,加入以下内容并保存;<?xml version='1.0' encoding='utf-8'?><tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="123456" roles="manager-gui,manager-script"/></tomcat-users>
Maven中配置 Tomcat 服务器
<server> <id>tomcat</id> <username>admin</username> <password>123456</password></server>
Tomcat Maven插件配置
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <path>/web_project_template</path> <uriEncoding>UTF-8</uriEncoding> <finalName>web_project_template</finalName> <server>tomcat</server> </configuration></plugin>
运行
-------------参考《网易云课堂.Java Web开发入门》
- maven 入门
- maven 入门
- MAVEN 入门
- Maven入门
- maven入门
- maven入门
- Maven 入门
- Maven入门
- maven 入门
- Maven入门
- maven入门
- maven 入门
- maven入门
- Maven入门
- maven入门
- Maven入门
- maven入门
- Maven入门
- JavaWeb JSP技术(上)
- Android控制文字水平间距android:letterSpacing
- 浏览器页面加载性能
- 解决Windows下载(Downloads)目录打开速度异常慢的问题
- 浅析 AngularJS 全球化最优方案(三)
- Maven入门
- js,easyui关闭当前的窗口!
- 浅析 AngularJS 全球化最优方案(四)
- 锐速Linux和谐版一键包
- CodeForces 471B MUH and Important Things 模拟 水
- 蓝鸥Unity开发基础——For语句学习笔记
- cpufreq之实例分析.
- iOS swift-归档与解档
- IO多路复用之select函数详解