zoukankan      html  css  js  c++  java
  • [七月挑选]使用idea创建spring boot 项目


    title: 使用idea创建spring boot 项目

    参考lindaZ的IntelliJ IDEA 创建spring boot 的Hello World 项目

    
    1.Open IDEA,choose "New-->Project"
    
    2.Choose "Spring Initializr"
    
    -> next
    
    3.Project Metadata:
    
    Group: com.chanchifeng
    Artifact: server-system
    Description: server-system project for Spring Boot
    
    -> next
    
    4. Choose "Web"
    
    -> next
    
    5.删除.mvn,mvnw,mvnw.cmd。
    
    

    创建HelloController

    
    	HelloController.java:
    
    	package com.chanchifeng.serversystem;
    	
    	import org.springframework.boot.SpringApplication;
    	import org.springframework.boot.autoconfigure.SpringBootApplication;
    	import org.springframework.context.annotation.ComponentScan;
    
    	@SpringBootApplication
    	@ComponentScan("com.chanchifeng.serversystem.ctrl")
    	public class ServerSystemApplication {
    	
    	    public static void main(String[] args) {
    	        SpringApplication.run(ServerSystemApplication.class, args);
    	    }
    	}
    
    

    修改HelloController

    
    	package com.chanchifeng.serversystem.ctrl;
    	
    	import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    	import org.springframework.web.bind.annotation.RequestMapping;
    	import org.springframework.web.bind.annotation.RestController;
    	
    	/**
    	 * @author:porschan
    	 * @description:
    	 * @date: Created in 10:14 2018/6/15
    	 * @modified By:
    	 */
    	
    	@RestController
    	@EnableAutoConfiguration
    	public class HelloController {
    	
    	    @RequestMapping("/hello")
    	    public String index(){
    	        System.out.println("进入controller");
    	        return "Hello World!";
    	    }
    	}
    
    
    

    运行com.chanchifeng.serversystem.ServerSystemApplication#main,在浏览器输入http://localhost:8080/hello,spring Boot项目搭建成功。

    本博客来自https://chanchifeng.com/2018/06/15/idea-springboot/

  • 相关阅读:
    hdu 1754 I Hate It
    hdu 2546 饭卡
    hdu 4506 小明系列故事——师兄帮帮忙
    hdu 3665 Seaside
    hdu 3790 最短路径问题
    hdu 1869 六度分离
    最长递增字串的三种做法
    问题集???
    IOS开发学习 碎片S
    超级台阶 (NYOJ—76)
  • 原文地址:https://www.cnblogs.com/chanchifeng/p/9253131.html
Copyright © 2011-2022 走看看