1maven role concept

The role of 1.maven

  a. jar package management

  i. increase third-party jar package (spring-context.jar spring-aop.jar ....)

  Ii.jar dependency between packets (automatically associated spring-context.jar configured to download all the Jar-dependent, and not conflict, no compatibility issues)

 

  b. Place the split items into several modules  

  For example: three-tier architecture

  maven can be split into three modules Layer

 

2.Maven concept:

  Is a build automation tool based on Java platform  

maven build process:

Cleanup (clean): Delete the results compiled in preparation for the recompilation.
Compilation (compile): java-> class
test (test): the project carried out for the key point test, the project can also be used in the test code to test the development code;
Report: The results of the tests carried out show
package (package): The the plurality of files contained in the project compressed into a file, for installation or deployment. (Java project -jar, web project -war)
installation (install): The resulting package into the local repository for other projects.
Deployment: The resulting package into server on ready to run. PS : Similar to add items into the inside of this process is to deploy tomcat

 

Local Warehouse

 

-Eclipse中部署的web项目可以运行
-将Eclipse中的项目,复制到tomcat/webapps中则不能运行
-打包后的项目可以在webappas中直接运行

Eclipse中的项目 ,在部署时 会生成一个 对应的 部署项目(在wtpwebapps中),区别在于: 部署项目 没有源码文件src(java),只有编译后的class文件和jsp文件
因为二者目录结构不一致,因此tomcat中无法直接运行 Eclips中复制过来的项目 (因为 如果要在tomcat中运行一个项目,则该项目 必须严格遵循tomcat的目录结构)

Eclipse中的项目 要在tomcat中运行,就需要部署: a.通过Eclipse中Add and Remove按钮进行部署
b.将Web项目打成一个war包,然后将该war包复制到tomcat/webapps中 即可执行运行

 

自动化构建工具maven:将 原材料(java、js、css、html、图片)->产品(可发布项目)

编译-打包-部署-测试 --> 自动化构建

 

     

使用maven
约定 优于 配置
比如有一个job对象以下有三种方式设置路径

硬编码方式:job.setPath("d:\\abc") ;
配置方式:
job
conf.xml <path>d:\\abc</path>

约定:使用默认值d:\\abc
job

maven约定的目录结构:
项目
 -src
  --main :程序功能代码
    --java java代码 (Hello xxx)
    --resources 资源代码、配置代码
  --test :测试代码
    --java
    --resources
 -target :存放编译后的文件
 pom.xml

<groupId>域名翻转.大项目名</groupId>
<groupId>org.chen.maven</groupId>

<artifactId>子模块名</artifactId>
<artifactId>HelloWorld</artifactId>


<version>版本号</version>
<version>0.0.1-SNAPSHOT</version>

maven的约定:执行项目进main,测试项目进test

 

 

 

 

ps:以上有些资料来自颜群老师,侵权可以联系我删除。

Guess you like

Origin www.cnblogs.com/unlasting/p/12193964.html