博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Eclipse搭建SpringBoot之HelloWorld
阅读量:6958 次
发布时间:2019-06-27

本文共 2067 字,大约阅读时间需要 6 分钟。

 

 

你的eclipse需要先安装

第一种方法(不建议,之所以贴上是因为探索的过程)

首先新建Maven工程

 勾选第一个按钮,第三个是选择working set ,你可以不选

下一步,配置工程信息,注意打包为jar

 

 打开pom.xml文件,添加spring-boot依赖

org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-maven-plugin

 新建文件src/main/hello/HelloController.java

package hello;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController {    @RequestMapping("/")    public String hello(){        return "Greetings from Spring Boot!";    }}

新建src/main/hello/Application.java

package hello;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Application {    public static void main(String[] args) {        // http://localhost:8080/        SpringApplication.run(Application.class, args);    }}

运行Application

 

 出现一堆:

访问localhost:8080/

第二种方法(推荐)

File-》new-》other

 

  选择starter项目

 下一步

 下一步

勾选Web,Finish。可以看到项目结构与我们自己建的Maven有些不一样。

新建一个Controller

package com.example.demo;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController {    @RequestMapping("/")    public String hello(){        return "Welcome to start SpringBoot!";    }}

运行

运行结果

比起原来的Spring项目,构建过程简单多了

参照来源:https://www.cnblogs.com/LUA123/p/8110285.html

转载于:https://www.cnblogs.com/xianfengzhike/p/9159132.html

你可能感兴趣的文章
CSS选择器
查看>>
[警告]Duplicating managed version 4.12 for junit
查看>>
性能测试培训:WebSocket协议的接口性能之Jmeter
查看>>
2012年50个顶级的photoshop教程:(一)图形绘画类
查看>>
Linux-RHEL 7.2实验环境的搭建
查看>>
【安全牛学习笔记】端口扫描(二)
查看>>
php 获取月第一天和最后一天
查看>>
CentOS Linux安装JDK
查看>>
linux中对swap分区的管理
查看>>
wecenter屏蔽模板目录,防止别人访问到
查看>>
centos7源码搭建lamp基于模块化方式
查看>>
强大的nmcli命令独家揭秘
查看>>
信息系统项目管理师教程第3版教程 2017年9月出版
查看>>
StratoIO WebPrinter控件的下载与安装的步骤介绍
查看>>
SSH隧道
查看>>
virtualbox设置ubuntu的共享目录
查看>>
安卓调用webservice的一种方式及需注意的问题
查看>>
DIY 微信HD版共享
查看>>
python入门(四)python对文件的操作
查看>>
C# 使用接口进行排序
查看>>