下载地址 配置环境变量,注意path里面的新建maven要配置到bin目录,而mavenhome只需要到其文件夹就行 打开命令行输入mvn -v 查看结果
在plugin的installed中搜索关键词maven,有2个插件即是有安装插件
Maven所有的Jar包都是放到maven仓库当中 在项目当中是对仓库jar包的引用 Maven仓库
本地仓库:本地存放jar的目录私服:私人搭建的服务器,一般在企业内部局域网使用中央仓库:Maven内置了一个远程仓库的地址,它就是中央仓库Maven找jar包的过程 1.Maven查找引入jar包时, 会先到本地仓库当中查找,没有找到现到私服中找,也没有就去 到远程中央仓库查找. 2.找到后会下载到本地仓库,下次就不用到远程仓库了 3.最终都会把jar包下载到本地仓库 4.Maven工程最终引用的都是本地的jar包
设置本地仓库目录地址 默认本地仓库为 修改本地仓库地址 把maven安装目录config中setting.xml复制一份到.m2文件夹下
打开setting.xml修改本地仓库地址
就是第一次引用jar包时远程仓库在国外,需要翻墙,虽然可以下载但速度很慢,所以不如从阿里云镜像下载,由他去国外下载,而且每隔一段时间就从国外下载一次
validate 确保当前配置和 POM 的内容是有效的 clean 删除target目录下及其目录下的所有内容 mvn compile 将java文件编译成二进制放到target目录当中 test 运行测试用例 package 打包工程 install 把maven打成的包发布到本地仓库当中 第i个执行时, i之前的命令都会执行 以下命令了解即可
创建servlet 添加依赖(导包),在maven搜索Java Servlet API,下载4.0.1版本新建servlet
项目目录如下
对于pom.xml要配置以下东西
<build> <finalName>SSMMaven</finalName> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <verbose>true</verbose> <overwrite>false</overwrite> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency> </dependencies> </plugin> </plugins> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build>还要在resources中引入generatorConfig.xml,这是之前用代码写的MyBatis代码生成器,到文件夹SSM中找 双击maven中plugins中的mybatis-generator即可生成一系列domain,mapper,mapper接口
若http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd变红可通过alt+enter,fetch external resource来解决
具体看网课