1、概览: 属性绑定,热部署,源码导入,自动配置,数据源,mp,web组件,MVC,模版,redis,消息,docker,jenkins, SpringCloud.
2、比较权威的springBoot介绍:
3、环境要求:Spring Boot Reference documentation
4、热部署:
ctrl+shift+alt+/ compaire.autoMake.
配置文件放置位置4个。 file./config > file. > config/ > ./
5、核心特色:
- 1:SpringBootAppliction 自定义bannner ,K8s状态Application Availability State
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
} 2、外部化配置
spring:
application:
name: "myapp"
config:
import: "optional:file:./dev.properties"
spring:
config:
import: "file:/etc/config/myconfig[.yaml]"
k8s:
etc/
config/
myapp/
username
password
app:
name: "MyApp"
description: "${app.name} is a Spring Boot application"
my:
secret: "${random.value}"
number: "${random.int}"
bignumber: "${random.long}"
uuid: "${random.uuid}"
number-less-than-ten: "${random.int(10)}"
number-in-range: "${random.int[1024,65536]}" 3、@Profile("production")
4、任务执行和调度spring:
task:
execution:
pool:
max-size: 16
queue-capacity: 100
keep-alive: "10s"
spring:
task:
scheduling:
thread-name-prefix: "scheduling-"
pool:
size: 2 5、Test:
@SpringBootTest
@AutoConfigureMockMvc
class MyMockMvcTests {
@Test
void testWithMockMvc(@Autowired MockMvc mvc) throws Exception {
mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Hello World"));
}
// If Spring WebFlux is on the classpath, you can drive MVC tests with a WebTestClient
@Test
void testWithWebTestClient(@Autowired WebTestClient webClient) {
webClient
.get().uri("/")
.exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("Hello World");
}
}
class MyTests {
private TestRestTemplate template = new TestRestTemplate();
@Test
void testRequest() throws Exception {
ResponseEntity headers = this.template.getForEntity("https://myhost.example.com/example", String.class);
assertThat(headers.getHeaders().getLocation()).hasHost("other.example.com");
}
} 5、Web



