码迷,mamicode.com
首页 > 编程语言 > 详细

用Eclipse+Maven快速创建一个SpringBoot项目

时间:2018-12-12 17:42:30      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:分享图片   autoconf   end   tap   get   pack   数据   配置   ica   

1. 去https://start.spring.io/默认下载一个maven项目 Generate Project(懂的话也可以更改其中的配置)。

2. 打开Eclipse,导入刚刚解压的Maven项目。

3. 在demo下建立一个controller包,简单显示一点数据:

package com.example.demo.controller;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
@RequestMapping("/springboot")
public class HelloController {
	@RequestMapping("/hello")
    public String hello() {
        return "Hello Spring Boot";
    }
}

  注意:maven包下还需要引入以下dependency:

<!-- 引入@RestController和@RequestMapping -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

  然后Java Application运行DemoApplication,浏览器输入localhost:8080/springboot/hello即可看到

技术分享图片

,这样就搭建好了。

 

用Eclipse+Maven快速创建一个SpringBoot项目

标签:分享图片   autoconf   end   tap   get   pack   数据   配置   ica   

原文地址:https://www.cnblogs.com/clack/p/10109140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!