SpringBoot学习日志---初学SpringBoot

目录

学习目标

配置idea

页面说明

运行结果

学习目标

在idea中配置springboot,并且在浏览器中显示出来,Hello,SpringBoot

配置idea

SpringBoot学习日志---初学SpringBoot_第1张图片

 

 SpringBoot学习日志---初学SpringBoot_第2张图片

 

 SpringBoot学习日志---初学SpringBoot_第3张图片

 

 SpringBoot学习日志---初学SpringBoot_第4张图片

 

 页面说明

 SpringBoot学习日志---初学SpringBoot_第5张图片

 

YcrkApplication.java
/**
 * @SpringBootApplication注解说明
 * @SpringBootApplication = (默认属性)@Configuration + @EnableAutoConfiguration + @ComponentScan。
 * 
 * @Configuration+@Bean。使用这两个注解就可以创建一个简单的spring配置类,可以用来替代相应的xml配置文件。
 * @Configuration的注解类标识这个类可以使用Spring IoC容器作为bean定义的来源。@Bean注解告诉Spring,
 * 一个带有@Bean的注解方法将返回一个对象,该对象应该被注册为在Spring应用程序上下文中的bean。
 *
 * @EnableAutoConfiguration:能够自动配置spring的上下文,试图猜测和配置你想要的bean类,通常会自动根据你的类路径和你的bean定义自动配置。
 *
 * @ComponentScan:会自动扫描指定包下的全部标有@Component的类,并注册成bean,当然包括@Component下的子注解@Service,@Repository,@Controller。
 */
@SpringBootApplication
public class YcrkApplication {

    public static void main(String[] args) {
        SpringApplication.run(YcrkApplication.class, args);
    }
}

pom.xml配置文件

SpringBoot学习日志---初学SpringBoot_第6张图片

 



    4.0.0

    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.3.1.RELEASE
         
    

    com.example
    ycrk
    0.0.1-SNAPSHOT
    ycrk
    Demo project for Spring Boot

    
    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter-webflux
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
        
            io.projectreactor
            reactor-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


  运行结果

添加代码文件HelloController

SpringBoot学习日志---初学SpringBoot_第7张图片

 

 

package com.example.ycrk.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("hello")
    public String hello(){
        return "Hello,Spring Boot!";
    }
}

 

运行

SpringBoot学习日志---初学SpringBoot_第8张图片

 

 

链接:http://127.0.0.1:8080/hello

SpringBoot学习日志---初学SpringBoot_第9张图片

 

你可能感兴趣的:(SpringBoot学习日志---初学SpringBoot)