1.安装运行环境 javaJdk
https://www.oracle.com/technetwork/java/javase/downloads/index.html
2.安装idea
https://www.jianshu.com/p/bcd1b188b0e7
3.配置idea
11
4.springBoot helloword pom.xml
新建一个controller
用@Controller 注明此类是一个控制器
@ResponseBody // 注释这是返回体函数
@RequestMapping("/test") // 设置路由路径
public String say (){
return "hello1121"; // 访问路由test 输出 返回值
}
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
5.热部署 spring-boot-devtools
6.配置文件 application.properties application.yaml
7.配置文件变量提示 spring-boot-configuration-processor
8.@Value方式读取配置文件
9.@PropertySource 和ImportResource
@PropertySource(value = {"classpath:person2.properties"} )
指定配置文件的路径
@ConfigurationProperties(prefix = "person2")
指定配置文件读取前缀啥
10.springboot的配置profiles详解
vmoptions -Dspring.profiles.active
java -jar **.jar --spring.
11.springboot的配置文件加载位置和优先加载顺序
12.web静态资源访问
classpath: /static
classpath: /public
classpath: /resources
classpath: /META-INF/Rresources
webjars
12.web模板
JSP,Velocity,Freemarker,Thymeleaf
路径classpath:/template
th:text="${}" 支持dsnl 表达式
13.springmvc的自动管理
- 中央转发器
- 控制器
- 视图解析器自动管理
- 静态资源访问
- 消息转换和格式化
webmvcautoConfig