spring boot编写并运行HelloWorld服务接口
生活随笔
收集整理的這篇文章主要介紹了
spring boot编写并运行HelloWorld服务接口
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
spring boot編寫并運行HelloWorld服務接口
在主程序上要加包掃描注解@ComponentScan(“com.example.demo1”)
package com.example.demo1;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan;@SpringBootApplication @ComponentScan("com.example.demo1") public class Demo1Application {public static void main(String[] args) {SpringApplication.run(Demo1Application.class, args);} }要運行的程序
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;@RestController public class HelloWorld {@RequestMapping("/hello")public String sayHello(){return "hello world";} }總結
以上是生活随笔為你收集整理的spring boot编写并运行HelloWorld服务接口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spring boot web jar说
- 下一篇: spring boot配置文件详解