前言
记录时间:2023.3.26
已坚持的第二十八天
java从入门到精通
学习java时间历程记录打卡
早上7:00到 12:00
下午2:00到 6:00
JavaWeb-maven和SpringBootWeb入门总结
完成代码练习
1.认识maven
1.配置maven的pom.xml
<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>
<groupId>cn.vqqc</groupId>
<artifactId>maven-project01</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-project01</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--依赖配置-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.6</version>
</dependency>
<!-- <scope>test</scope>-->
</dependencies>
<!-- 打包插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals><goal>single</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2.依赖包关系
1.maven-projectA
<?xml version="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.0</modelVersion>
<groupId>cn.vqqc</groupId>
<artifactId>maven-projectA</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>cn.vqqc</groupId>
<artifactId>maven-projectB</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 排除依赖-->
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
2.maven-projectB
<?xml version="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.0</modelVersion>
<groupId>cn.vqqc</groupId>
<artifactId>maven-projectB</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>cn.vqqc</groupId>
<artifactId>maven-projectC</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
</project>
3.maven-projectC
<?xml version="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.0</modelVersion>
<groupId>cn.vqqc</groupId>
<artifactId>maven-projectC</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
</project>
2.SpringBootWeb入门
1.请求处理类
package cn.vqqc.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//请求处理类
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello(){
System.out.println("Hello World!");
return "Hello world";
}
}
2.启动类
package cn.vqqc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//启动类
@SpringBootApplication
public class SpringWebQuickstartApplication {
public static void main(String[] args) {
SpringApplication.run(SpringWebQuickstartApplication.class, args);
}
}
3.spring的pom.xml配置
<?xml version="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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cn.vqqc</groupId>
<artifactId>spring-web-quickstart</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-web-quickstart</name>
<description>spring-web-quickstart</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
视频总结
1. maven-课程介绍
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=50
2. maven-概述-介绍&安装
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=51
3. maven-idea集成-配置及创建maven项目
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=52
4. maven-idea集成-导入maven项目
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=53
5. maven-依赖管理-依赖配置
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=54
6. maven-依赖管理-依赖传递
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=55
7. maven-依赖管理-依赖范围
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=56
8. maven-依赖管理-生命周期
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=57
9. Web入门-课程介绍
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=58
10. Web入门-SpringBootWeb-快速入门
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=59
11. Web入门-HTTP协议-概述
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=60
12. Web入门-HTTP协议-请求协议
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=61
13. Web入门-HTTP协议-响应协议
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=62
14. Web入门-HTTP协议-协议解析
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=63
15. Web入门-Tomcat-介绍
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=64
16. Web入门-Tomcat-基本使用
https://www.bilibili.com/video/BV1m84y1w7Tb/?p=65
暂无评论内容