随笔分类 - springboot2
摘要:路径变量@PathVariable ①获取指定路径变量: @GetMapping("/car/{id}/owner/{userName}") public Map<String,Object> getCar(@PathVariable("id") int id, @PathVariable("use
阅读全文
摘要:欢迎页 将index.html放入默认的静态资源路径下,会默认访问。 访问路径:http://localhost:8080/ 如下设置了项目的根访问路径,则欢迎页访问需使用:http://localhost:8080/my/ spring:# mvc:# static-path-pattern: /
阅读全文
摘要:默认静态资源目录 类路径下:/static、/public、/resources、/META-INF/resources 以下路径下静态资源可直接访问,如http://localhost:8080/hu4.jpeg 原理:静态映射/** 请求进来,先看controller能不能处理,不能处理的所有请
阅读全文
摘要:package com.java.boot.config; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.boot.c
阅读全文
摘要:import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component//组件加入容器中 @Conf
阅读全文
摘要:条件装配:满足Conditional指定的条件,则进行组件注入 @Configuration//告诉springboot这是一个配置类 public class MyConfig { @Bean("tom") public Stu stu01(){ return new Stu("汤姆"); } @
阅读全文
摘要:import boot.bean.Stu; import boot.bean.User; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configu
阅读全文
摘要:①创建maven工程 ②pom.xml中添加父工程,集成springboot父项目 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <ve
阅读全文
摘要:父工程pom.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001
阅读全文