SpringBoot簡易搭建

1.創建maven工程java

2.打開pom文件, 將如下配置拷貝過去web

 1 <parent>
 2        <groupId>org.springframework.boot</groupId>
 3        <artifactId>spring-boot-starter-parent</artifactId>
 4        <version>1.5.8.RELEASE</version>
 5    </parent>
 6    <dependencies>
 7        <dependency>
 8            <groupId>org.springframework.boot</groupId>
 9            <artifactId>spring-boot-starter-web</artifactId>
10        </dependency>
11        <dependency>
12             <groupId>org.springframework.boot</groupId>
13             <artifactId>spring-boot-starter</artifactId>
14         </dependency>
15    </dependencies>

3.java文件內啓動springboot, 並編寫一個測試方法來測試spring

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class App 
{
    public static void main( String[] args )
    {
        SpringApplication.run(App.class, args);
    }
    
    @Controller
    public class TestController {
    	@RequestMapping("/hello")
    	@ResponseBody
    	public String hello() {
    		return "hello";
    	}
    }
}

4.打開java文件,右鍵==> Run As==> Java Application, 等待啓動完成, 瀏覽器測試顯示以下瀏覽器

相關文章
相關標籤/搜索