赞
踩
分模块开发对工程有什么好处?
目的:项目的扩展性变强了,方便其他项目引用相同的功能。


一个完整的工程依据什么来进行模块的拆分?

注意事项:
mvn install
注意事项:
依赖管理指当前项目运行所需的jar,一个项目可以设置多个依赖
格式:
<!--设置当前项目所依赖的所有jar-->
<dependencies>
<!--设置具体的依赖-->
<dependency>
<!--依赖所属群组id-->
<groupId>org.springframework</groupId>
<!--依赖所属项目id-->
<artifactId>spring-webmvc</artifactId>
<!--依赖版本号-->
<version>5.2.10.RELEASE</version>
</dependency>
</dependencies>
A依赖B,B依赖C,A是否依赖于C呢?

A依赖B,B依赖C,如果A不想将C依赖进来,是否可以做到?
<dependency>
<groupId>com.itheima</groupId>
<artifactId>maven_03_pojo</artifactId>
<version>1.0-SNAPSHOT</version>
<!--可选依赖是隐藏当前工程所依赖的资源,隐藏后对应资源将不具有依赖传递性-->
<optional>false</optional>
</dependency>
A依赖B,B依赖C,如果A不想将C依赖进来,是否可以做到?
<dependency> <groupId>com.itheima</group Id> <artifactId>maven_04_dao</artifactId> <version>1.0-SNAPSHOT</version> <!--排除依赖是隐藏当前资源对应的依赖关系--> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </exclusion> </exclusions> </dependency>

什么叫聚合?
聚合:将多个模块组织成一个整体,同时进行项目构建的过程称为聚合
聚合工程:通常是一个不具有业务功能的”空“工程(有且仅有一个pom文件)
作用:使用聚合工程可以将多个工程编组,通过对聚合工程进行构建,实现对所包含的模块进行同步构建

工程的打包方式有哪几种?
<packaging>pom</packaging>
注意事项:
<modules>
<module>../maven_ssm</module>
<module>../maven_pojo</module>
<module>../maven_dao</module>
</modules>
注意事项:
什么叫继承?

<packaging>pom</packaging>
注意事项:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
……
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.16</version>
</dependency>
……
</dependencies>
</dependencyManagement>
<!--定义该工程的父工程-->
<parent>
<groupId>com.itheima</groupId>
<artifactId>maven_parent</artifactId>
<version>1.0-SNAPSHOT</version>
<!--填写父工程的pom文件,根据实际情况填写-->
<relativePath>../maven_parent/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
</dependencies>
注意事项:
聚合和继承的作用?
定义属性有什么好处?

<!--定义自定义属性-->
<properties>
<spring.version>5.2.10.RELEASE</spring.version>
<junit.version>4.12</junit.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<!--定义自定义属性-->
<properties>
<spring.version>5.2.10.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<jdbc.url>jdbc:mysql://127.0.0.1:3306/ssm_db</jdbc.url>
</properties>
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=${jdbc.url}
jdbc.username=root
jdbc.password=root
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

项目开发的版本可以分为哪几种?

多环境配置有什么好处?

<!--定义多环境--> <profiles> <!--定义具体的环境:生产环境--> <profile> <!--定义环境对应的唯一名称--> <id>env_dep</id> <!--定义环境中专用的属性值--> <properties> <jdbc.url>jdbc:mysql://127.0.0.1:3306/ssm_db</jdbc.url> </properties> <!--设置默认启动--> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <!--定义具体的环境:开发环境--> <profile> <id>env_pro</id> …… </profile> </profiles>
【命令】:
mvn 指令 –P 环境定义id
【范例】:
mvn install –P pro_env
跳过测试会不会影响项目的构建过程?
注意事项:
<plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <skipTests>true</skipTests> <!--设置跳过测试--> <includes> <!--包含指定的测试用例--> <include>**/User*Test.java</include> </includes> <excludes> <!--排除指定的测试用例--> <exclude>**/User*TestCase.java</exclude> </excludes> </configuration> </plugin>
这里的私服和平时我们听的国服、体验服、欧服等等有什么区别?
团队开发现状分析
私服是一台独立的服务器,用于解决团队内部的资源共享与资源同步问题
Nexus

启动服务器(命令行启动)
访问服务器(默认端口:8081)
修改基础配置信息
修改服务器运行配置信息

私服仓库分为哪几种?

往私服上传资源是否需要身份认证?在哪里设置认证信息?

【第一步】在maven的settings.xml中<mirrors>标签中配置,此时就需要注释掉aliyun的配置。
<mirror>
<id>nexus-heima</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
【第二步】在nexus中设置允许匿名下载,如果不允许将不会从私服中下载依赖

如果私服中没有对应的jar,会去中央仓库下载,速度很慢。可以配置让私服去阿里云中下载依赖。

【第一步】配置本地仓库访问私服的权限(在maven的settings.xml的servers标签中配置)
<server>
<!--id任意,多个server的id不重复就行,后面会用到-->
<id>heima-nexus</id>
<username>admin</username>
<password>123456</password><!--填写自己nexus设定的登录秘密-->
</server>
【第一步】配置当前项目访问私服上传资源的保存位置(项目的pom.xml文件中配置)
<distributionManagement>
<repository>
<!--和maven/settings.xml中server中的id一致,表示使用该id对应的用户名和密码-->
<id>heima-nexus</id>
<!--如果jar的版本是release版本,那么就上传到这个仓库,根据自己情况修改-->
<url>http://localhost:8081/repository/heima-releases/</url>
</repository>
<snapshotRepository>
<!--和maven/settings.xml中server中的id一致,表示使用该id对应的用户名和密码-->
<id>heima-nexus</id>
<!--如果jar的版本是snapshot版本,那么就上传到这个仓库,根据自己情况修改-->
<url>http://localhost:8081/repository/heima-snapshots/</url>
</snapshotRepository>
</distributionManagement>
注意:要和maven的settings.xml中server中定义的<id>heima-nexus</id>对应
【第三步】发布资源到私服命令
mvn deploy
对应的用户名和密码–>
heima-nexus
http://localhost:8081/repository/heima-releases/
heima-nexus
http://localhost:8081/repository/heima-snapshots/
**==注意:要和maven的settings.xml中server中定义的\<id>heima-nexus\</id>对应==**
【第三步】发布资源到私服命令
mvn deploy
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。