修改项目端口号
在application.properties配置文件中输入server.post=8081 重启项目即可修改端口号。
原理初探
在pom.xml中
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
点击进入spring-boot-starter-parent底层,ctrl+鼠标左键
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
spring-boot-dependencies存储核心依赖,在父工程中
在写和引入Springboot的时候,不需要引入版本,在工程已经全部导入
启动器
<!--启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
启动器:Springboot启动场景
它会将所有的功能场景,全部都变成启动器
如果需要使用什么功能,直接找到启动器即可
主程序
package com.ty.study;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//标注这个项目是一个Springboot的项目
@SpringBootApplication
public class StudyApplication {
//将springboot启动,通过反射
public static void main(String[] args) {
SpringApplication.run(StudyApplication.class, args);
}
}
点击SpringBootApplication进入底层,查看
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration //核心
@EnableAutoConfiguration //核心
@ComponentScan( //扫描下面的包 配置扫描
excludeFilters = {@Filter(
type = FilterType.CUSTOM,
classes = {TypeExcludeFilter.class}
), @Filter(
type = FilterType.CUSTOM,
classes = {Au