赞
踩
1.创建步骤

2. 编码添加
2.1 这是自动生成的启动函数
- package com.example.comxjctest4;
-
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
-
- @SpringBootApplication
- public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
- }
2.2 添加一个controler
- package com.example.comxjctest4;
-
- import org.springframework.web.bind.annotation.Mapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
-
- @RestController
- public class CTest {
- @RequestMapping("/h")
- public String h(){
- return "h";
- }
- }
3 要点记录
@SpringBootApplication 这个注解保证了会对你创建再工程下的类进行扫描。扫描后的类有回用户被框架管理的功能。
@RestController 这个注解表示是该类会被当做controller处理
@RequestMapping("/h") 这个注解表示映射的http地址栏中的地址
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。