栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot学习笔记

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot学习笔记

pom.xml
  • spring-boot-dependencies(版本仓库):核心依赖在父工程中,父工程记录了所有第三方jar包的版本号
  • 我们在引入或写入springboot依赖时,可以不要指定版本号,就是因为有版本仓库在。

启动器

可参考基本启动器44种

        
            org.springframework.boot
            spring-boot-starter
        
  • 启动器:简单来说就是springboot的使用场景
  • 例如spring-boot-starter-web,他会帮助我们自动导入web环境所有的依赖
  • springboot会将所有的功能场景,变成一个个的启动器
  • 需要什么功能,就只需要找到对应的启动器即可。"strater-???"

主程序

//@SpringBootApplication:标注这个类是springboot的应用
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        //run:将springboot应用启动
        SpringApplication.run(DemoApplication.class, args);
    }
}

@SpringBootApplication注解:有以下几个父注解

@Target

@Documented

@Retention

@Inherited

@SpringBootConfiguration

@EnableAutoConfiguration

@ComponentScan

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
    excludeFilters = {@Filter(
    type = FilterType.CUSTOM,
    classes = {TypeExcludeFilter.class}
), @Filter(
    type = FilterType.CUSTOM,
    classes = {AutoConfigurationExcludeFilter.class}
)}
)

起关键作用的两个注解

@SpringBootConfiguration :springboot的配置
     @Configuration :spring配置类 
         @Component:说明这也是一个spring的组件


@EnableAutoConfiguration : 自动配置
     @AutoConfigurationPackage :自动配置包
           @Import({Registrar.class}) :自动配置“包注册”
     @Import({AutoConfigurationImportSelector.class}) :自动配置导入选择


//获取所有的配置
List configurations = getCandidateConfigurations(annotationMetadata,attributes);

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/945534.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号