当前位置:   article > 正文

idea 创建 spring boot

idea 创建 spring boot

1.创建步骤

 2. 编码添加

2.1 这是自动生成的启动函数

  1. package com.example.comxjctest4;
  2. import org.springframework.boot.SpringApplication;
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;
  4. @SpringBootApplication
  5. public class Application {
  6. public static void main(String[] args) {
  7. SpringApplication.run(Application.class, args);
  8. }
  9. }

2.2 添加一个controler

  1. package com.example.comxjctest4;
  2. import org.springframework.web.bind.annotation.Mapping;
  3. import org.springframework.web.bind.annotation.RequestMapping;
  4. import org.springframework.web.bind.annotation.RestController;
  5. @RestController
  6. public class CTest {
  7. @RequestMapping("/h")
  8. public String h(){
  9. return "h";
  10. }
  11. }

3 要点记录

@SpringBootApplication 这个注解保证了会对你创建再工程下的类进行扫描。扫描后的类有回用户被框架管理的功能。
@RestController 这个注解表示是该类会被当做controller处理
@RequestMapping("/h") 这个注解表示映射的http地址栏中的地址
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/46794
推荐阅读
相关标签
  

闽ICP备14008679号