使用maven的好处

John Casey
standardization
reuse
consistency wrt build output
dependency management
scalability (lower level of additional info/code to add a new step to the build process)
Ashley williams
Dependency management
Build lifecycle management
Large existing repository
Eclipse aware (sort of)
Well documented (hopefully soon)
Eric Hartmann
One directory layout,
A single way to define dependencies,
Setting up a project is really fast,
99% of my needs are available out of the box,
Transitive dependencies ! :-)
Vincent Massol
common build structure
build best practices enforcement (shared build meme)
automated build of application, from source code to pre-production platform => fast time to market with reduced risks
works well with distributed teams ;-) Location doesn't matter.
Compared to Ant:

Higher level of reusability between builds
Faster turn around time to set up a powerful build (once you're used to Maven)
Less maintenance
Shared build meme. I know how to build any maven project
Greater momentum: Ant is now legacy and not moving fast ahead. Maven is forging ahead fast and there's a potential of having lots of high-value tools around Maven (CI, Dashboard project, IDE integration, etc).
Emmanuel Venisse
All artifacts are versionned and store in a repository
build process is standardized for all projects
a lot of goals are available so it isn't necessary to develop some specific build process part contrary to ANT we can reuse existing ANT tasks in build process with antrun plugin
it provide quality project information with generated site
Easy to learn and use
David Jackman
Dependency management
Makes the build process much easier at the project level (i.e. don't have to create very much for each project for Maven to build it correctly, and those things you do create are more declarative than functional)
Automatic project web sites with consistent information about each project
Recommended standards and best practices for project layout and definition
Jesse Mcconnell
Promotes modular design of code. by making it simple to manage mulitple projects it allows the design to be laid out into muliple logical parts, weaving these parts together through the use of dependency tracking in pom files.
Enforces modular design of code. it is easy to pay lipservice to modular code, but when the code is in seperate compiling projects it is impossible to cross pollinate references between modules of code unless you specifically allow for it in your dependency management... there is no 'I'll just do this now and fix it later' implementations.
Dependency Management is clearly declared. with the dependency management mechanism you have to try to screw up your jar versioning...there is none of the classic problem of 'which version of this vendor jar is this?' And setting it up on an existing project rips the top off of the existing mess if it exists when you are forced to make 'unknown' versions in your repository to get things up and running...that or lie to yourself that you know the actual version of ABC.jar.
strong typed life cycle there is a strong defined lifecycle that a software system goes thru from the initiation of a build to the end... and the users are allowed to mix and match their system to the lifecycle instead of cobble together their own lifecycle.. this has the additional benefit of allowing people to move from one project to another and speak using the same vocabulary in terms of software building
Henning
quick project setup, no complicated build.xml files, just a POM and go
all developers in a project use the same jar dependencies due to centralized POM.
getting a number of reports and metrics for a project "for free"
reduce the size of source distributions, because jars can be pulled from a central location
Roberto Castro
Consistency in artifact naming
Use of remote repository
Web site generation
1.[今日课程内容总览] Maven--***** 介绍 优点 用maven创建一个项目, 用maven创建一个ssm项目,每一层的代码分开,把一个项目拆解成多个项目 2.[今日包含笔记] maven介绍: Eclise: 缺点: Jar包: 版本管理,解决jar包冲突:删除老的jar包,保留新的jar包 不同的项目,jar包要复制一份;Users Library 羡慕yum的好处,安装软件,自动下载,自动验证,自动安装,自动测试;镜像网站 Jar包的依赖: 致命的缺点:现象: 每一个项目都有前台(广大网民)和后台(管理员看的),后台的功能远远的大于>前台的功能;迭代升级;每次升级都要重启tomcat;将tomcat做很多个备份(10个),为了nginx转发;前台:访问比较大,管理员访问量比较小; 问题: 每次升级,10个tomcat都升级一次 后台的升级频繁要比前台频繁;升级10次,9次改的是后台的代码,只有一次是前台的代码 解决方案: 是将前台(广大网民看的页面)的代码和后台(管理员)的代码要分开,将原来的一个项目分别放到两个web项目;一个web项目一个tomcat;好处:更新的时候如果更新后台(管理员),只需要重启后台的tomcat(服务); 折成两个项目以后的缺点:Service以下的代码重复; 将Service层以下的代码放到一个新创建的java项目中,在部署的时候将Service(java项目)打成一个jar包,分别放到两个web服务中;编译的时候让web项目依赖与Service(java项目)_source folder;配置麻烦,项目与项目之间的依赖头脑得相当清晰 这个缺点Maven解决了; 请听今天的内容 拆分前:图一 拆分后是图二 3. 介绍 官网:http://maven.apache.org/download.cgi 目录介绍: Bin:二进制文件 Boot:引导,启动 Conf:配置文件 Lib:jar包 README.txt:读我 3.1.修改配置文件的内容 路径:%MAVEN_HOME%\conf\settings.xml 配置文件代码: d:/repo alimaven aliyun maven http://maven.aliyun.com/nexus/content/groups/public/ central 注意: 千万不要将文档中的setting的内容全部替换到maven中的内容,要对比着修改,保留原来的; 只修改本地仓库,和下载镜像(源) 3.2.Eclipse Maven的配置 每打开一个新的工作空间,要配置一下Maven,然后再写代码 3.3.创建Maven项目 右击创建一个maven project Packing:有三种: Jar:java项目, War:web项目 Pom:文件夹,jar和war文件,mavenProject:一个项目,可以放jar和war包,通过pom,一般新创建的maven Project是POM 3.4.创建一个Maven Model 最外面的项目是MavenProject,其它的全部是Maven Model 3.4.1.创建JAR 目录介绍: Mvn-jar |-->Src:源码:java代码 |-->|-->main:代码:除测试以外的代码:junit |-->|-->main|-->java:代码 |-->|-->main|-->resources:配置文件 |-->|-->test:测试的代码,junit |-->|-->test|-->java:代码 |-->|-->test|-->resources:配置文件 |-->Target:编译后的文件 |-->|-->classes:代码编译后的class类 |-->|-->test-classes:测试类编译后的classes 3.4.2.创建WAR 目录介绍: Mvn-war |-->Src:源码:java代码 |-->|-->main:代码:除测试以外的代码:junit |-->|-->main|-->java:代码 |-->|-->main|-->resources:配置文件 |-->|-->main|-->webapp:webContent,一般放jsp,js,css |-->|-->test:测试的代码,junit |-->|-->test|-->java:代码 |-->|-->test|-->resources:配置文件 |-->Target:编译后的文件 |-->|-->classes:代码编译后的class类 |-->|-->test-classes:测试类编译后的classes |-->|-->m2e-wtp:编译后的web服务;war解压后的内容 创建war包以后报以下错误: 因为创建的web项目,webapps少了web-inf,web.xml 解决方案: 在项目上右击,Javaee Tools-->第二个选项 3.5.配置编译环境 将maven的项目重新编译,在项目中右击,可以pom上右击,可以将pom(目录)下面的jar和war重新编译 如果出现以上情况,说明下载的jar包有问题,把这下面的文件删除,重新下载 每创建一个项目,都有pom.xml,所有的配置都在pom.xml中 网址:所有的groupId和artifactId到这个网站中找 http://mvnrepository.com/ Pom.xml:配置文件示例(含的编译环境) 4.0.0 com.bjsxt mvn 0.0.1-SNAPSHOT pom mvn mvn mvn-jar mvn-war org.apache.maven.plugins maven-surefire-plugin true org.apache.maven.plugins maven-compiler-plugin <!-- 3.6.1 --> 1.7 1.7 UTF-8 org.apache.maven.plugins maven-source-plugin true compile jar org.apache.maven.plugins maven-resources-plugin UTF-8 3.6.生命周期 Maven -build:javac;编译 Maven-install:java先编译,后运行 在项目的target中会生成jar包和war包, 在仓库中生成相应的目录,里面的放的是jar包和war包 Maven-clean:会把项目中的class文件和jar包war包删除 Maven-test:运行所的测试类,取决于位置,必须放到src/test下面;在运行的(install)跳过,运行的时候会执行一遍测试类(花的时间长) 4.创建一个标准的ssm项目 项目介绍: Ssm:项目的顶级目录 ssm_common:jar包,放的是原来src_common下面的代码 ssm_service:pom,文件夹,放了api和impl的项目 ssm_service_api:jar包,放的是所有Service的接口 ssm_service_impl:jar包,所有Service的实现类 ssm_service_back:管理员后台的web服务 ssm_service_head:前台的服务 凡是依赖:如果都是java项目,会将依赖的项目打成一个jar包放到classpath中, 如果是web项目,会将依赖的项目打成一个jar包,放到web-inf/lib中 特别的图 创建完以后如下图: 添加依赖 5.搭建ssm 5.1.创建数据库 5.2.创建项目:确定项目可以在tomcat上运行 5.3.添加Spring 添加jar包 添加JAR包 增加版本的常量 在不同的项目中可以使用不同的版本-这种情况不允许 添加配置文件 写测试代码 如下图: 结论: ~将原来的原始的项目,变成maven项目 ~相同的代码,不同的环境,将项目跑起来 5.4.添加Mybatis 将service折成了两个项目:service-api,和service-impl Service-api;放的是Controller层使用到的对象;Service的接口引用,Util,POJO, Service-impl:放的是调用Dao层的对象; 目前来看:我们的web服务都依赖了api服务和impl服务,在将来引用dubbo的时候,web服务只依赖api服务,不依赖Impl
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值