了解,讲得并不是很好,很展开。
概念



动态web


Web服务器
web服务器这节也是蜻蜓点水,引出tomcat而已
- ASP(C#语言,微软)
- JSP
- PHP



Java bootstrapclassloader加载机制就是从rt.jar中来的。
tomcat或者其他软件,中间件使用步骤:
****
Tomcat详解
Tomcat下载安装
- 官网下载
- 解压下载的压缩包,就能得到tomcat
- 配置环境变量——网上找

Tomcat服务器启动/停止
Tomcat目录说明

启动/停止



网站是如何进行访问的

web网站的目录结构

HTTP
一般般带过


http请求

http响应



其他:
调整网页请求速度

Maven
基础的maven安装,只是最普通的入门,需要找其他视频深入
概述



配置环境变量


阿里云镜像
<localRepository>D:/mavenRepository</localRepository>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
Idea中使用maven















pom.xml是maven的核心配置文件


maven中pom.xml项目用到的配置说明
<?xml version="1.0" encoding="UTF-8"?>
<!--maven版本和头文件-->
<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.0</modelVersion>
<!--maven项目有父模块或者比如使用springboot构建项目时会用到parent-->
<!-- <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>-->
<!--项目的GAV,即组、项目名和版本号-->
<groupId>com.roy</groupId>
<artifactId>maven-web-service</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 项目的打包方式 jar:java应用 war:javaweb应用-->
<packaging>war</packaging>
<!--项目名-->
<name>maven-web-service</name>
<!-- 项目对外url地址-->
<url>http://www.example.com</url>
<!--配置-->
<properties>
<!-- 项目的默认构建编码-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 在Maven的一些插件使用中需要输出一些报告,而输出报告的编码格式是需要我们进行设定的,因为这些插件的默认编码不是统一的(后面会提到)。在此需求上,希望能提供一种更为轻松简单的方式进行配置,即使用一个默认值来控制所有的报告输出的编码。-->
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- 项目执行编译的java版本-->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- 自定义版本properties,统一管理版本号-->
<!-- 获取方式: <version>${spring-cloud-alibaba.version}</version>-->
<spring-cloud-alibaba.version>2.1.1.RELEASE</spring-cloud-alibaba.version>
</properties>
<!--项目依赖-->
<dependencies>
<dependency>
<!-- 具体依赖的jar包,分别填入GAV,scope标签表示该jar包的作用范围,-->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.75</version>
</dependency>
<!-- maven的高级之处就是会帮我们导入这个jar包所依赖的其他jar包-->
<!-- 这样我们就不需要关心这个jar包依赖的jar,只需要关心我们想要直接依赖的jar包即可-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.8.RELEASE</version>
</dependency>
</dependencies>
<!--父模块预先定义要依赖的jar包和版本,子模块直接在dependencies标签中引用GA,组和项目名,无需版本号-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!--远程仓库地址配置-->
<repositories>
<repository>
<id>roy-releases</id>
<name>Repository</name>
<url>http://172.116.16.111:8081/repository/roy-releases/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>roy-snapshots</id>
<name>Repository</name>
<url>http://172.116.16.111:8081/repository/roy-snapshots/</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>aliyun-repos</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<!--远程插件仓库配置-->
<pluginRepositories>
<pluginRepository>
<id>repository</id>
<name>Repository</name>
<url>http://172.16.16.11:8081/repository/roy-public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<!-- 项目构建用的东西-->
<build>
<!-- 解决配置文件资源导出问题-->
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<!-- maven插件-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>utf-8</encoding>
<useDefaultDelimiters>true</useDefaultDelimiters>
</configuration>
</plugin>
</plugins>
</build>
<!-- 环境配置-->
<profiles>
<!--开发环境 -->
<profile>
<id>fedudev</id>
<properties>
<profileActive>edudev</profileActive>
<discovery.namespace/>
<config.namespace>${discovery.namespace}</config.namespace>
<nacos.config.address>172.16.16.235:59102</nacos.config.address>
<nacos.discovery.address>${nacos.config.address}</nacos.discovery.address>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
<!--测试环境 -->
<profile>
<id>fedutest</id>
<properties>
<profileActive>edutest</profileActive>
<discovery.namespace>c84254ac-03ed-4331-8841-f8e2e0b7a036</discovery.namespace>
<config.namespace>${discovery.namespace}</config.namespace>
<nacos.config.address>172.16.16.235:59102</nacos.config.address>
<nacos.discovery.address>${nacos.config.address}</nacos.discovery.address>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
</profiles>
</project>
Maven依赖中scope标签的作用域详解
scope的分类
compile(编译范围)
默认就是compile,什么都不配置也就是意味着compile。compile表示被依赖项目需要参与当前项目的编译,当然后续的测试,
运行周期也参与其中,是一个比较强的依赖。打包的时候通常需要包含进去。
test(测试范围)
scope为test表示依赖项目仅仅参与测试相关的工作,包括测试代码的编译,执行。比较典型的如junit。
PS: test表示只能在src下的test文件夹下面才可以使用,你如果在a项目中引入了这个依赖,在b项目引入了a项目作为依赖,在b项目中这个注解不会生效,因为scope为test时无法传递依赖。
runntime(运行时范围)
runntime表示被依赖项目无需参与项目的编译,不过后期的测试和运行周期需要其参与。与compile相比,跳过编译而已,
说实话在终端的项目(非开源,企业内部系统)中,和compile区别不是很大。比较常见的如JSR×××的实现,对应的API jar是compile的,
具体实现是runtime的,compile只需要知道接口就足够了。Oracle jdbc驱动架包就是一个很好的例子,一般scope为runntime。
另外runntime的依赖通常和optional搭配使用,optional为true。我可以用A实现,也可以用B实现。
provided(已提供范围)
provided意味着打包的时候可以不用包进去,别的设施(Web Container)会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。相当于compile,但是在打包阶段做了exclude的动作。
例如, 如果你开发了一个web 应用,你可能在编译 classpath 中需要可用的Servlet API 来编译一个servlet,但是你不会想要在打包好的WAR 中包含这个Servlet API;
这个Servlet API JAR 由你的应用服务器或者servlet 容器提供。已提供范围的依赖在编译classpath (不是运行时)可用。它们不是传递性的,也不会被打包。
system(系统范围)
system范围依赖与provided 类似,但是你必须显式的提供一个对于本地系统中JAR 文件的路径。这么做是为了允许基于本地对象编译,
而这些对象是系统类库的一部分。这样的构件应该是一直可用的,Maven 也不会在仓库中去寻找它。如果你将一个依赖范围设置成系统范围,
你必须同时提供一个 systemPath 元素。注意该范围是不推荐使用的(你应该一直尽量去从公共或定制的 Maven 仓库中引用依赖)。
scope的依赖传递
A–>B–>C。当前项目为A,A依赖于B,B依赖于C。知道B在A项目中的scope,那么怎么知道C在A中的scope呢?答案是:
当C是test或者provided时,C直接被丢弃,A不依赖C;否则A依赖C,C的scope继承于B的scope。

maven无法导出配置文件问题
maven由于其约定大于配置,由此可能在之后的项目中遇到我们写的配置文件无法导出或者生效的问题,解决方案便是在pom.xml文件中加入resource标签取消过滤文件。
无法导出案例:在使用MyBatis框架时,往往Mapper.xml配置文件都会放在dao包中和dao接口类放在一起的,那么执行程序的时候,其中的xml配置文件就一定会读取失败,不会生成到maven的target目录中 。
处理逻辑:标准的Maven项目都会有一个resources目录来存放我们所有的资源配置文件,但是我们往往在项目中不仅仅会把所有的资源配置文件都放在resources中,同时我们也有可能放在项目中的其他位置,那么默认的maven项目构建编译时就不会把我们其他目录下的资源配置文件导出到target目录中,就会导致我们的资源配置文件读取失败,从而导致我们的项目报错出现异常,比如说尤其我们在使用MyBatis框架时,往往Mapper.xml配置文件都会放在dao包中和dao接口类放在一起的,那么执行程序的时候,其中的xml配置文件就一定会读取失败,不会生成到maven的target目录中,所以我们要在项目的pom.xml文件中进行设置 。
如果有其他格式的配置文件如yml文件就再加上<include>**/*.yml</include>
过滤。
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
Maven3.6.2版本的问题
Maven3.6.2版本不能很好得使用,会报依赖的jar包依赖不上。
查看idea日志

其他
typora对代码块格式化代码快捷键:选中代码块中要格式化的代码或者全选,shift+tab
网友评论