springboot笔记截图

 

 

 

 

 

 

 

 

 

 

 

 

 

 

文字版本


//自动生成框架之后
1.  修改pom文件
 <!--继承父项目-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    <!--导入web依赖-->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
2.编写主程序(来启动springboot框架)
        @SpringBootApplication:来标注springboot主程序类,说明这是一个springboot应用
3.启动主程序
        编写main方法,使用SpringApplication类来启动框架
4.编写业务逻辑(hellowoldcontroller.class)
         @Controller   可以处理请求
         @RequestMapping  映射路径
         @ResponseBody  json



一.pom文件深究
    springboothelloword的父项目
    	 <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.5.9.RELEASE</version>
            </parent>
    	的父项目
    		<parent>
        		<groupId>org.springframework.boot</groupId>
        		<artifactId>spring-boot-dependencies</artifactId>
        		<version>1.5.9.RELEASE</version>
        		<relativePath>../../spring-boot-dependencies</relativePath>
        	</parent>
        	它来真正管理spring boot应用里面的所有的依赖版本
        	springboot的版本仲裁中心
        	以后导入依赖不需要写版本号,(没有在dependencies里面管理的依赖,自然需要管理版本号)

二.导入的依赖
            <!--导入web依赖-->
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </dependency>
            </dependencies>
            spring-boot-starter     web
            spring-boot-starter------>springboot的场景启动器

            spring boot 将所有的场景都抽取出来,做成一个个的starter(启动器),只需要在项目里面引入这些starter
            相关场景的所有以来都会导进来,要用什么功能就导入什么场景的启动器
            (启动器网址:https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/html/using-boot-build-systems.html#using-boot-starter)

三.主程序类,主入口类
            /**
             * 来标注springboot主程序类,说明这是一个springboot应用
             * **/
            @SpringBootApplication
            public class HelloWorldMainApplication {
                public static void main(String[] args){
                    //spring应用启动起来(传入的类必须是@SpringBootApplication标注的类)
                    SpringApplication.run(HelloWorldMainApplication.class,args);

                }
            }
             @SpringBootApplication     此注解标注在某一个类上,说明这个类是spring boot的主配置类
                                        springboot就应该运行这个类的main方法来启动springboot应用
              @SpringBootApplication是一个组合注解,包含一下几种注解
              ---------------------------------------------------------------------
              --@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}
             -- )}
             -- )
             -- public @interface SpringBootApplication {
              ----------------------------------------
               @SpringBootConfiguration ----->springboot的配置类
               @EnableAutoConfiguration ----->开启自动配置功能
                    将主配置类(有@SpringBootApplication标注的类)所在的包及子包所有的
                    组件(比如hellowoldcontroller.java)都扫描到spring容器中
               @Import({EnableAutoConfigurationImportSelector.class})
                    给容器中导入组件
                    EnableAutoConfigurationImportSelector:导入哪些组件的选择器
                    将所有需要导入的组件以全类名的方式返回,这些组件就会添加到容器中
                    会给容器中导入非常多的自动配置类

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞飞翼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值