Spring Boot笔记(1)Spring Boot入门——更新中

一、Spring Boot 入门

1、Spring Boot 简介

2、微服务

3、环境准备

1、MAVEN设置




  
  /Volumes/storage/maven_repository

  
  
  
  
  
  

      
          
          nexus-aliyun
          *
          Nexus aliyun
          http://maven.aliyun.com/nexus/content/groups/public
      
  
    
      

  
  
  
      
      
          jdk1.8
          
              true
              1.8
          
          
              UTF-8
              1.8
              1.8
              1.8
          
      
      
      
          dev
          
              
                  nexus
                  http://nexus.hepengju.cn:8081/nexus/content/groups/public/
                  
                      true
                  
                  
                      true
                  
              
          
          
              
                  public
                  Public Repositories
                  http://nexus.hepengju.cn:8081/nexus/content/groups/public/
              
          
      
      
      
          ali
          
              
                  alimaven
                  aliyun maven
                  http://maven.aliyun.com/nexus/content/groups/public/
                  
                      true
                  
                  
                      true
                  
              
          
          
              
                  alimaven
                  aliyun maven
                  http://maven.aliyun.com/nexus/content/groups/public/
              
          
      
  

   
  
      jdk1.8
      dev
      ali
  


2、IDEA设置

设置JDK以及MAVEN关联

4、Spring Boot Hello World

1、创建一个MAVEN工程

2、导入依赖Spring Boot 相关的依赖


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


    
        org.springframework.boot
        spring-boot-starter-web
    

3、编写一个主程序:启动Spring Boot应用

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

4、编写相关的Controller、Service

@Controller
public class HelloController {
    @ResponseBody
    @RequestMapping("/hello")
    public String hello(){
        return "Hello World";
    }
}

5、运行测试


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

将应用package打包成jar包,直接使用java -jar命令运行

P6 00:00

代码地址

你可能感兴趣的:(Spring Boot笔记(1)Spring Boot入门——更新中)