当前位置 : 主页 > 编程语言 > c++ >

第一个SpringBoot项目配置示例

来源:互联网 收集:自由互联 发布时间:2021-07-03
pom.xml 4.0.0 com.luo.demo demo 1.0-SNAPSHOT jar org.springframework.boot spring-boot-starter-parent 1.5.6.RELEASE UTF-8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-maven-plugin Application.java @Sp
pom.xml
 

 
    
  
   4.0.0
  

    
  
   com.luo.demo
  
    
  
   demo
  
    
  
   1.0-SNAPSHOT
  

    
  
   jar
  

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

    
   
   
    UTF-8
    
  

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

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


 
Application.java
@SpringBootApplication
public class Application {

    public static void main(String[] args) throws InterruptedException {

        SpringApplication.run(Application.class, args);

    }

}
IndexController.java
@RestController
@RequestMapping("/")
public class IndexController {

    @GetMapping("/")
    public String index() {
        return "hello world";
    }

    @GetMapping("/hello/{msg}")
    public String hello(@PathVariable("msg") String msg) {
        return "hello " + msg;
    }

}
网友评论