分模块开发对工程有什么好处?
一个完整的工程依据什么来进行模块的拆分?
mvn install
<dependencies>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>5.3.18version>
dependency>
dependencies>
A依赖B,B依赖C,A是否依赖于C呢?
A依赖B,B依赖C,如果A不想将C依赖进来,是否可以做到?
<dependency>
<groupId>com.itheimagroupId>
<artifactId>maven_03_pojoartifactId>
<version>1.0-SNAPSHOTversion>
<optional>falseoptional>
dependency>
A依赖B,B依赖C,如果A不想将C依赖进来,是否可以做到?
<dependency>
<groupId>com.itheimagroupId>
<artifactId>maven_04_daoartifactId>
<version>1.0-SNAPSHOTversion>
<exclusions>
<exclusion>
<groupId>log4jgroupId>
<artifactId>log4jartifactId>
exclusion>
<exclusion>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
exclusion>
exclusions>
dependency>
什么叫聚合?
工程的打包方式有哪几种?
<packaging>pompackaging>
<modules>
<module>../maven_02_ssmmodule>
<module>../maven_03_pojomodule>
<module>../maven_04_daomodule>
modules>
什么叫继承?
<packaging>pompackaging>
<dependencies>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>5.2.10.RELEASEversion>
dependency>
……
dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druidartifactId>
<version>1.1.16version>
dependency>
……
dependencies>
dependencyManagement>
<parent>
<groupId>com.itheimagroupId>
<artifactId>maven_parentartifactId>
<version>1.0-SNAPSHOTversion>
<relativePath>../maven_parent/pom.xmlrelativePath>
parent>
<dependencies>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druidartifactId>
dependency>
dependencies>
聚合和继承的作用?
<properties>
<spring.version>5.2.10.RELEASEspring.version>
<junit.version>4.12junit.version>
properties>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-contextartifactId>
<version>${spring.version}version>
dependency>
<properties>
<spring.version>5.2.10.RELEASEspring.version>
<junit.version>4.12junit.version>
<jdbc.url>jdbc:mysql://127.0.0.1:3306/ssm_db?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=truejdbc.url>
properties>
db.driver=com.mysql.cj.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/ssm_db?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
db.username=root
db.password=root
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resourcesdirectory>
<filtering>truefiltering>
resource>
resources>
build>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-war-pluginartifactId>
<version>3.2.3version>
<configuration>
<failOnMissingWebXml>falsefailOnMissingWebXml>
configuration>
plugin>
项目开发的版本可以分为哪几种?
多环境配置有什么好处?
<profiles>
<profile>
<id>env_depid>
<properties>
<jdbc.url>jdbc:mysql://127.0.0.1:3306/ssm_db?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=truejdbc.url>
properties>
<activation>
<activeByDefault>trueactiveByDefault>
activation>
profile>
<profile>
<id>env_proid>
……
profile>
profiles>
【命令】:
mvn 指令 –P 环境定义id
【范例】:
mvn install –P pro_env
跳过测试会不会影响项目的构建过程?
mvn install –D skipTests
<plugin>
<artifactId>maven-surefire-pluginartifactId>
<version>2.22.1version>
<configuration>
<skipTests>trueskipTests>
<includes>
<include>**/User*Test.javainclude>
includes>
<excludes>
<exclude>**/User*TestCase.javaexclude>
excludes>
configuration>
plugin>
这里的私服和平时我们听的国服、体验服、欧服等等有什么区别?
【第一步】在maven的settings.xml中
<mirror>
<id>nexus-heimaid>
<mirrorOf>*mirrorOf>
<url>http://localhost:8081/repository/maven-public/url>
mirror>
【第二步】在nexus中设置允许匿名下载,如果不允许将不会从私服中下载依赖
如果私服中没有对应的jar,会去中央仓库下载,速度很慢。可以配置让私服去阿里云中下载依赖。
【第一步】配置本地仓库访问私服的权限(在maven的settings.xml的servers标签中配置)
<server>
<id>heima-nexusid>
<username>adminusername>
<password>adminpassword>
server>
【第二步】配置当前项目访问私服上传资源的保存位置(项目的pom.xml文件中配置)
<distributionManagement>
<repository>
<id>heima-nexusid>
<url>http://localhost:8081/repository/heima-releases/url>
repository>
<snapshotRepository>
<id>heima-nexusid>
<url>http://localhost:8081/repository/heima-snapshots/url>
snapshotRepository>
distributionManagement>
注意:要和maven的settings.xml中server中定义的
【第三步】发布资源到私服命令
mvn deploy