package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//这里是程序入口
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//加注解,然后定义helloworld
@RestController
public class HellolWorld {
@RequestMapping("/hello")
public String helloworld(){
return "Hello World ";
}
}
程序启动后,访问http://127.0.0.1:8080/hello,这没什么好讲的,你只要配置没问题,实现这个很容易;