springboot 創建一個HelloWorld應用並且運行


1.創建一個helloworld主程序類

/**
* @SpringBootApplication 用來標注一個主程序類,這是一個SpringBoot應用
*/
@SpringBootApplication
public class SpringBootHellowordConfigApplication {

public static void main(String[] args) {

//Spring應用啟動
SpringApplication.run(SpringBootHellowordConfigApplication.class,args);
}

}

2.寫一個controller

@Controller
public class HelloController {

@ResponseBody
@RequestMapping("/hello")
public String helloController(){
return "hello controller";
}

}
3.運行主配置類,后查看端口號
  

4.瀏覽器運行:http://localhost:8081/hello 即可
 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM