目录
maven高级应用:
- maven基础回顾。
- maven传统的web工程做一个数据查询操作。
- maven工程拆分与聚合的思想。
- 把第二阶段做好的web工程修改成maven拆分与聚合的形式。
- 私服【远程仓库】。
- 如何安装第三方jar包【把第三方jar包安装到本地仓库,把第三方jar包安装到私服】。
maven基础知识回顾
maven是一个项目管理工具。
依赖管理:maven对项目中jar包的管理过程。传统工程我们直接把jar包放置在项目中。
maven工程真正的jar包放置在仓库中,项目中只用放置jar包的坐标。
仓库的种类:本地仓库、远程仓库(私服)、中央仓库。1.本地仓库:自己电脑上的仓库。
2.远程仓库(私服):放置公司内部开发所需的jar包。
3.中央仓库:本地仓库(可以联网的前提下)联网之后从中央仓库下载jar包。
仓库之间的关系:当我们启动一个maven工程的时候,maven工程会通过pom文件中jar包的坐标去本地仓库找对应jar包。
默认情况下,如果本地仓库没有对应jar包,maven工程会自动去中央仓库下载jar包到本地仓库中。
在公司中,如果本地没有对应jar包,会先从私服下载jar包;如果私服没有jar包,可以从中央仓库下载,也可以从本地上传。
一键构建:maven自身集成了tomcat插件,可以对项目进行编译、测试、打包、安装、发布等操作。
maven常用命令:clean-清理项目之前有过的构建信息、compile-对src目录下的java文件进行编译、test-编译后进行测试、package-打包本地项目、install-把包安装到本地仓库、deploy-把本地做好的项目直接打包上传到私服。
maven三套生命周期:清理生命周期、默认生命周期、站点生命周期。
- /*
- Navicat MySQL Data Transfer
- Source Server : localhost_3306
- Source Server Version : 50096
- Source Host : localhost:3306
- Source Database : maven_ssm
- Target Server Type : MYSQL
- Target Server Version : 50096
- File Encoding : 65001
- Date: 2018-04-23 14:07:06
- */
-
- SET FOREIGN_KEY_CHECKS=0;
- -- ----------------------------
- -- Table structure for `items`
- -- ----------------------------
- DROP TABLE IF EXISTS `items`;
- CREATE TABLE `items` (
- `id` int(10) NOT NULL auto_increment,
- `name` varchar(20) default NULL,
- `price` float(10,0) default NULL,
- `pic` varchar(40) default NULL,
- `createtime` datetime default NULL,
- `detail` varchar(200) default NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-
- -- ----------------------------
- -- Records of items
- -- ----------------------------
- INSERT INTO `items` VALUES ('1', '传智播客', '1000', null, '2018-03-13 09:29:30', '带我走上人生巅峰');
- INSERT INTO `items` VALUES ('2', '黑马310', null, null, '2018-03-28 10:05:52', '插入测试');
- INSERT INTO `items` VALUES ('3', '黑马307', '199', null, '2018-03-07 10:08:04', '插入测试');
- INSERT INTO `items` VALUES ('7', '插入测试', null, null, null, null);
- INSERT INTO `items` VALUES ('8', '插入测试', null, null, null, null);
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
- "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.0modelVersion>
-
- <groupId>com.itheimagroupId>
- <artifactId>maven_day02_1artifactId>
- <version>1.0-SNAPSHOTversion>
- <packaging>warpackaging>
-
- <dependencies>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-beansartifactId>
- <version>4.2.4.RELEASEversion>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-contextartifactId>
- <version>5.0.2.RELEASEversion>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-coreartifactId>
- <version>4.2.8.RELEASEversion>
- dependency>
- dependencies>
- project>
- "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.0modelVersion>
-
- <groupId>com.itheimagroupId>
- <artifactId>maven_day02_1artifactId>
- <version>1.0-SNAPSHOTversion>
- <packaging>warpackaging>
-
-
- <dependencies>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-beansartifactId>
- <version>4.2.4.RELEASEversion>
- <exclusions>
- <exclusion>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-coreartifactId>
-
- exclusion>
- exclusions>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-contextartifactId>
- <version>5.0.2.RELEASEversion>
- dependency>
-
- dependencies>
- project>
- "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.0modelVersion>
-
- <groupId>com.itheimagroupId>
- <artifactId>maven_day02_1artifactId>
- <version>1.0-SNAPSHOTversion>
- <packaging>warpackaging>
-
-
-
- <properties>
- <spring.version>5.0.2.RELEASEspring.version>
- <slf4j.version>1.6.6slf4j.version>
- <log4j.version>1.2.12log4j.version>
- <shiro.version>1.2.3shiro.version>
- <mysql.version>5.1.6mysql.version>
- <mybatis.version>3.4.5mybatis.version>
- <spring.security.version>5.0.1.RELEASEspring.security.version>
- properties>
-
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-contextartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-webartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-webmvcartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-txartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-testartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.mybatisgroupId>
- <artifactId>mybatisartifactId>
- <version>${mybatis.version}version>
- dependency>
- dependencies>
- dependencyManagement>
-
-
- <dependencies>
-
- <dependency>
- <groupId>org.aspectjgroupId>
- <artifactId>aspectjweaverartifactId>
- <version>1.6.8version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-aopartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-contextartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-context-supportartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-webartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-ormartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-beansartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-coreartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-testartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-webmvcartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>org.springframeworkgroupId>
- <artifactId>spring-txartifactId>
- <version>${spring.version}version>
- dependency>
- <dependency>
- <groupId>junitgroupId>
- <artifactId>junitartifactId>
- <version>4.12version>
- <scope>testscope>
- dependency>
- <dependency>
- <groupId>mysqlgroupId>
- <artifactId>mysql-connector-javaartifactId>
- <version>${mysql.version}version>
- dependency>
- <dependency>
- <groupId>javax.servletgroupId>
- <artifactId>javax.servlet-apiartifactId>
- <version>3.1.0version>
- <scope>providedscope>
- dependency>
- <dependency>
- <groupId>javax.servlet.jspgroupId>
- <artifactId>jsp-apiartifactId>
- <version>2.0version>
- <scope>providedscope>
- dependency>
- <dependency>
- <groupId>jstlgroupId>
- <artifactId>jstlartifactId>
- <version>1.2version>
- dependency>
-
- <dependency>
- <groupId>log4jgroupId>
- <artifactId>log4jartifactId>
- <version>${log4j.version}version>
- dependency>
- <dependency>
- <groupId>org.slf4jgroupId>
- <artifactId>slf4j-apiartifactId>
- <version>${slf4j.version}version>
- dependency>
- <dependency>
- <groupId>org.slf4jgroupId>
- <artifactId>slf4j-log4j12artifactId>
- <version>${slf4j.version}version>
- dependency>
-
- <dependency>
- <groupId>org.mybatisgroupId>
- <artifactId>mybatisartifactId>
- <version>${mybatis.version}version>
- dependency>
- <dependency>
- <groupId>org.mybatisgroupId>
- <artifactId>mybatis-springartifactId>
- <version>1.3.0version>
- dependency>
- <dependency>
- <groupId>c3p0groupId>
- <artifactId>c3p0artifactId>
- <version>0.9.1.2version>
- <type>jartype>
- <scope>compilescope>
- dependency>
- <dependency>
- <groupId>com.github.pagehelpergroupId>
- <artifactId>pagehelperartifactId>
- <version>5.1.2version>
- dependency>
- <dependency>
- <groupId>org.springframework.securitygroupId>
- <artifactId>spring-security-webartifactId>
- <version>${spring.security.version}version>
- dependency>
- <dependency>
- <groupId>org.springframework.securitygroupId>
- <artifactId>spring-security-configartifactId>
- <version>${spring.security.version}version>
- dependency>
- <dependency>
- <groupId>org.springframework.securitygroupId>
- <artifactId>spring-security-coreartifactId>
- <version>${spring.security.version}version>
- dependency>
- <dependency>
- <groupId>org.springframework.securitygroupId>
- <artifactId>spring-security-taglibsartifactId>
- <version>${spring.security.version}version>
- dependency>
- <dependency>
- <groupId>com.alibabagroupId>
- <artifactId>druidartifactId>
- <version>1.0.9version>
- dependency>
- dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.tomcat.mavengroupId>
- <artifactId>tomcat7-maven-pluginartifactId>
- <version>2.2version>
- plugin>
- plugins>
- build>
- project>
- package com.itheima.dao;
-
- import com.itheima.domain.Items;
-
- public interface ItemsDao {
- public Items findById(Integer id);
- }
- "1.0" encoding="UTF-8" ?>
- mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.itheima.dao.ItemsDao">
- <select id="findById" parameterType="int" resultType="items">
- select * from items where id = #{id}
- select>
- mapper>
- "1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="jdbc:mysql:///maven"/>
- <property name="username" value="root"/>
- <property name="password" value="root"/>
- bean>
-
-
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
-
- <property name="typeAliasesPackage" value="com.itheima.domain"/>
- bean>
-
-
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.itheima.dao"/>
- bean>
-
- beans>
- package com.itheima.test;
-
- import com.itheima.dao.ItemsDao;
- import com.itheima.domain.Items;
- import org.junit.jupiter.api.Test;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
-
- public class ItemsTest {
- @Test
- public void findById() {
- //获取spring容器
- ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
- //从容器中拿到所需的dao代理对象
- ItemsDao itemsDao = ac.getBean(ItemsDao.class);
- //调用方法
- Items items = itemsDao.findById(1);
- System.out.println(items.getName());
- }
- }
- "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.0modelVersion>
-
- <groupId>org.examplegroupId>
- <artifactId>maven_day02_parentartifactId>
- <packaging>pompackaging>
- <version>1.0-SNAPSHOTversion>
- <modules>
- <module>maven_day02_daomodule>
- <module>maven_day02_servicemodule>
- <module>maven_day02_webmodule>
- modules>
-
- <properties>
- <maven.compiler.source>8maven.compiler.source>
- <maven.compiler.target>8maven.compiler.target>
- properties>
-
- <dependencies>
- <dependency>
- <groupId>org.examplegroupId>
- <artifactId>maven_day02_serviceartifactId>
- <version>1.0-SNAPSHOTversion>
- dependency>
- dependencies>
- project>
计算机类公众号:
(01)我爱计算机视觉
(02)Cver
(03)Datawhale
(04)量子位
(05)极市平台
(06)新智元
(07)机器之心
(08)AI算法与图像处理
(09)Opencv学堂
(10)PaperWeekly
(11)机器学习算法工程师
(12)AI研习社
(13)GiantPandaCV
(14)AI深度学习视线
(15)七月在线实验室
(16)人工智能前沿讲习
(17)AI科技评论
(18)机器学习算法与Python精研
(19)AIZOO
(20)微软研究员AI头条
(21)VALSE
(22)AI算法修炼营
(23)有三AI
(24)AlWalker
(25)AI公园
(26)AI人工智能初学者
(27)计算机视觉之路
(28)小白学视觉
(29)HyperAI超神经
(30)集智书童
(31)计算机视觉life
(32)CV圈
(33)计算机视觉研究院
(34)深度学习与计算机视觉
(35)机器学习研习院
(36)机器学习与生成对抗网络