
SpringBoot学习笔记
动 力 小 子
笔记随便写的,一般都是给自己看的,各位能看的懂的话可以当作参考。
展开
-
12-@EnableAutoConfiguration注解
待编辑原创 2021-09-02 12:19:31 · 128 阅读 · 0 评论 -
11-@Import注解
1.@Import注释导入bean1.@Import(xxx.class)2.通过Ioc容器context.getBean(xxx.class)获取beanpackage com.example.demo;import com.itheima.config.EnableUser;import com.itheima.config.UserConfig;import com.itheima.domain.User;import org.springframework.boot.Spri原创 2021-09-02 12:10:29 · 241 阅读 · 0 评论 -
10-@Enable*注解
Spring提供了一系列以Enable开头的注解,这些注解本质上是激活Spring的某些管理功能。比如,EnableWebMvc。 这个注解引入了MVC框架在Spring 应用中需要用到的所有bean。另外一个注解式EnableAsync, 它让Bean在spring 应用中支持异步功能。1.依赖groupId个人有所不同 <dependency> <groupId>com.itheima</groupId>原创 2021-08-20 00:15:34 · 223 阅读 · 0 评论 -
09-自动配置--@Condition注解
Condition注解用于选择性加载Bean时候使用(相当于条件判断)1.创建一个Bean,这里创建了一个User2.写User的配置类UserConfigimport com.example.demo.condition.ClassCondition;import com.example.demo.domain.User;import org.springframework.context.annotation.Bean;import org.springframework.co...原创 2021-08-19 20:50:48 · 1309 阅读 · 0 评论 -
08-SpringBoot整合其他框架
1.Junit导入依赖classes = "引导类里run方法里的"SpringApplication.run(DemoApplication.class)package com.ithemima.test;import com.itheima.springboottest.DemoApplication;import com.itheima.springboottest.UserService;import org.junit.jupiter.api.Test;import.原创 2021-08-16 23:04:34 · 143 阅读 · 0 评论 -
07-SpingBoot配置加载顺序
# 应用名称spring.application.name=demo# 应用服务 WEB 访问端口server.port=8080#修改项目默认访问路径server.servle.context-path=/hello原创 2021-08-15 22:49:32 · 106 阅读 · 0 评论 -
06-动态配置切换---profile/yml
1.profile 1.1 文件命名-dev(开发环境)/pro(生产)/test(测试) 1.2 于application.properties中激活##激活配置文件spring.profiles.active=dev2.yml方式用---分隔开,并使用string: profiles: name 给区域命名---server: port: 8081spring: profiles: dev #配置区域...原创 2021-08-15 22:11:11 · 345 阅读 · 0 评论 -
05-获取配置数据
1.@Value注释@Value("${name}") private String name; @Value("${person.name}") private String name2; @RequestMapping("/hello2") public String hello2(){ System.out.println(name); return name+"||"+name2; }2.Enviromen原创 2021-08-15 21:24:37 · 192 阅读 · 1 评论 -
04-YAML基础
1.YAML的基本语法2.YAML的数据格式对象(map):键值对的集合person: name: zhangsan#行内写法person:{name: zhangsan} 数组:一组按次序排列的值原创 2021-08-14 17:33:59 · 120 阅读 · 0 评论 -
03-SpringBoot配置
配置类型2种:properties,yml/yaml默认配置名称:application优先级:properties>yml>yaml原创 2021-08-14 17:02:06 · 122 阅读 · 0 评论 -
02-快速搭建SpringBoot项目
原创 2021-08-14 16:59:37 · 138 阅读 · 0 评论 -
01-SpringBoot学习笔记
前言:之前零零散散跟着项目学过SpringBoot,感觉基础不太稳固,所以重新再学一遍。第一章:HelloSpringBoot0.使用Maven创建项目1.在porm.xml配置以下代码<!--springboot工程需要继承的父工程--> <parent> <groupId>org.springframework.boot</groupId> <version>2.1.8.RELEA.原创 2021-08-14 16:16:53 · 214 阅读 · 0 评论