1,maven基础回顾。
2,maven传统的web工程做一个数据查询操作。
3,maven工程拆分与聚合的思想。
4,把第二阶段做好的web工程修改成maven拆分与聚合的形式。
5,私服【远程仓库】。
6,如何安装第三方jar包。【把第三方jar包安装到本地仓库,把第三方jar包安装到私服。】
maven是一个项目管理工具。
依赖管理:maven对项目中jar包的管理过程。传统工程我们直接把jar包放置在项目中。
maven工程真正的jar包放置在仓库中,项目中只用放置jar包的坐标。
仓库的种类:本地仓库,远程仓库【私服】,中央仓库。
仓库之间的关系:当我们启动一个maven工程的时候,maven工程会通过pom文件中jar包的坐标去本地仓库找对应jar包。
默认情况下,如果本地仓库没有对应jar包,maven工程会自动去中央仓库下载jar包到本地仓库。
在公司中,如果本地没有对应jar包,会先从私服下载jar包,
如果私服没有jar包,可以从中央仓库下载,也可以从本地上传。
一键构建:maven自身集成了tomcat插件,可以对项目进行编译,测试,打包,安装,发布等操作。
maven常用命令:clean,compile,test,package,install,deploy。
maven三套生命周期:清理生命周期,默认生命周期,站点生命周期。
<?xml version="1.0" encoding="UTF-8"?>
<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.itheima</groupId>
<artifactId>maven_day02_1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<!--maven工程要导入jar包的坐标,就必须要考虑解决jar包冲突。
解决jar包冲突的方式一:
第一声明优先原则:哪个jar包的坐标在靠上的位置,这个jar包就是先声明的。
先声明的jar包坐标下的依赖包,可以优先进入项目中。
maven导入jar包中的一些概念:
直接依赖:项目中直接导入的jar包,就是该项目的直接依赖包。
传递依赖:项目中没有直接导入的jar包,可以通过项目直接依赖jar包传递到项目中去。
解决jar包冲突的方式二:
路径近者优先原则。直接依赖路径比传递依赖路径近,那么最终项目进入的jar包会是路径近的直接依赖包。
解决jar包冲突的方式三【推荐使用】:
直接排除法。
当我们要排除某个jar包下依赖包,在配置exclusions标签的时候,内部可以不写版本号。
因为此时依赖包使用的版本和默认和本jar包一样。
-->
<!-- 统一管理jar包版本 -->
<properties>
<spring.version>5.0.2.RELEASE</spring.version>
<slf4j.version>1.6.6</slf4j.version>
<log4j.version>1.2.12</log4j.version>
<shiro.version>1.2.3</shiro.version>
<mysql.version>5.1.6</mysql.version>
<mybatis.version>3.4.5</mybatis.version>
<spring.security.version>5.0.1.RELEASE</spring.security.version>
</properties>
<!--
maven工程是可以分父子依赖关系的。
凡是依赖别的项目后,拿到的别的项目的依赖包,都属于传递依赖。
比如:当前A项目,被B项目依赖。那么我们A项目中所有jar包都会传递到B项目中。
B项目开发者,如果再在B项目中导入一套ssm框架的jar包,对于B项目是直接依赖。
那么直接依赖的jar包就会把我们A项目传递过去的jar包覆盖掉。
为了防止以上情况的出现。我们可以把A项目中主要jar包的坐标锁住,那么其他依赖该项目的项目中,
即便是有同名jar包直接依赖,也无法覆盖。
-->
<!-- 锁定jar包版本 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 项目依赖jar包 -->
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- log start -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- log end -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<!-- 添加tomcat7插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
工程不等于完整的项目,模块也不等于完整的项目,一个完整的项目看的是代码,代码完整,就可以说这是一个完整的项目
和此项目是工程和模块没有关系。
工程天生只能使用自己内部资源,工程天生是独立的。后天可以和其他工程或模块建立关联关系。
模块天生不是独立的,模块天生是属于父工程的,模块一旦创建,所有父工程的资源都可以使用。
父子工程直接,子模块天生集成父工程,可以使用父工程所有资源。
子模块之间天生是没有任何关系的。
父子工程直接不用建立关系,继承关系是先天的,不需要手动建立。
平级直接的引用叫依赖,依赖不是先天的,依赖是需要后天建立的