Maven的应用和个人理解(一)
在多人协作的项目开发过程中,SVN仅仅能做到代码的版本管理,对于开发人员来说,本地环境、测试环境、生产环境配置和应用都可能不同。而且每个人的开发习惯不同,引用的jar文件版本不同,势必会导致令人崩溃的包冲突问题。所以越来越多的人开始使用Maven来管理发布团队的项目。
对于maven许多人的理解都不同,开始我也只是觉得它只是一个比Ant更好用的项目构建工具而已,比如进行注预处理,编译,打包,测试和分发等操作,用来把源代码构建成可发布的构件。但是,通过这一段时间的学习,阅读了关于maven的文档之后,发现Maven的功能远远大于ant所关注的构建工程,可以的说它是ant的超集,引用文档上官方的定义来说:Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑。它遵从“约定大于配置”的原则,一个maven项目的包路径如下:
<profile> <id>development</id> <properties> <example.cookie.key>xLyhSVcQGix62o+t2fjZyx+bC+zQZCl2</example.cookie.key> <example.cookie.domain>.test.net</example.cookie.domain> <example.log.level>DEBUG</example.log.level> <example.log.path>d:/logs</example.log.path> <example.memcached1.address>10.10.10.2:111</example.memcached1.address> <example.memcached2.address>10.10.14.12:13222</example.memcached2.address> <example.struts.devMode>true</example.struts.devMode> <example.domain.name>example.test.net:8080</example.domain.name> <example.asset.domain.name>misc.test.net</example.asset.domain.name> <example.jdbc.datasource.type>dbcp</example.jdbc.datasource.type> <example.jdbc.driver>oracle.jdbc.driver.OracleDriver</example.jdbc.driver> <example.jdbc.url>jdbc:oracle:thin:@10.10.34.39:1521:testdb</example.jdbc.url> <example.jdbc.username>user</example.jdbc.username> <example.jdbc.password>user</example.jdbc.password> </properties></profile>