⿊马ssm学习笔记-Maven
摘要
maven⾼级应⽤:
1. maven基础回顾
2. maven传统的web⼯程做⼀个数据查询操作
3. maven⼯程拆分与聚合的思想
4. 把第⼆阶段做好的web⼯程修改成maven拆分与聚合的形式
5. 私服【远程仓库】
6. 如何安装第三⽅jar包。【把第三⽅jar包安装到本地仓库,把第三⽅jar包安装到私服】
maven基础回顾
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三套⽣命周期
清理⽣命周期,默认⽣命周期,站点⽣命周期
project做⼀个查询操作:maven_day02_1
<web-app xmlns="java.sun/xml/ns/javaee"
xsi="/2001/XMLSchema-instance"
schemaLocation="java.sun/xml/ns/javaee
java.sun/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
jar包冲突
⼯程要导⼊jar包的坐标,就必须要考虑解决jar包冲突。
解决jar包冲突的⽅式—:
第⼀声明优先原则:哪个jar包的坐标在靠上的位置,这个jar包就是先声明的。先声明的jar包坐标下的依赖包,可以优先进⼊项⽬中。
maven导⼊jar包的⼀些概念
直接依赖:项⽬中直接导⼊的jar包,就是该项⽬的直接依赖包。
传递依赖,项⽬中没有直接导⼊的jar包,可以通过项⽬直接依赖jar包传递到项⽬中
解决jar包冲突的⽅式⼆:
路径近者优先原则。直接依赖路径⽐传递依赖路径近,那么最终项⽬进⼊到jar包会是路径近的直接依赖包。
解决jar包冲突的⽅式三【推荐使⽤】:
当我们要排除某个jar包下依赖包,在配置exclusions标签的时候,内部可以不写版本号。因为此时依赖包使⽤的版本和默认和本jar包⼀样。
SSM框架依赖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>
<!-- 锁定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&batis</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&batis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId&batis</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>
maven打包本地jar包<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>
</dependencies>
<!-- 添加tomcat7插件 -->
<build>
<plugins>
<plugin>
<groupId>at.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
<web-app xmlns="java.sun/xml/ns/javaee"
xsi="/2001/XMLSchema-instance"
schemaLocation="java.sun/xml/ns/javaee
java.sun/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/schema/beans"
xmlns:xsi="/2001/XMLSchema-instance"
xmlns:context="/schema/context"
xmlns:aop="/schema/aop"
xmlns:tx="/schema/tx"
xmlns:mvc="/schema/mvc"
xsi:schemaLocation="/schema/beans /schema/beans/spring-beans.xsd
/schema/context
/schema/context/spring-context.xsd /schema/aop
/schema/aop/spring-aop.xsd
/schema/tx
/schema/tx/spring-tx.xsd
/schema/mvc
/schema/mvc/spring-mvc.xsd">
</beans>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论