springboot项目搭建——直接生成项目架构

Posted 打杂工程师

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot项目搭建——直接生成项目架构相关的知识,希望对你有一定的参考价值。

spring-Boot是Spring的新东东,为了让人尽快的使用,它提供了一个非常好的辅助工具,直接为我们生成Maven架构的工程。下面,我们通过helloworld看


一、在浏览器中打开http://start.spring.io/,如图

在Artifact中输入spring-boot-sample-helloworld,点击“Switch to the full version.”,勾选"web",然后点击“ Generate Project alt +”按钮,把文件保存到本地某个位置

二、下载文件导入eclips

1、解压下载的文件到某个文件夹;

2、在eclips中导入工程file->import->Import Existing Maven Projects-->Select Maven projects-->finish


3、在eclips中运行工程,正确则入图

三、添加HelloController


1、在包com.example中点击右键,选择new->class,再在Name中输入HelloController,入下图


在上图中点击"Finish"

2、在类上面条件声明@RestController


3、增加方法
package com.lcy.demo.tool;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;
@RestController public class SummerTest
    @RequestMapping("/")     String home()         return "Hello World!";    
    @RequestMapping("/hello/myName")     String index(@PathVariable String myName)         return "Hello " + myName + "!!!";    
4、启动测试

在浏览器中依次输入

http://localhost:8080/


http://localhost:8080/hello/上帝



以上是关于springboot项目搭建——直接生成项目架构的主要内容,如果未能解决你的问题,请参考以下文章

MVC四层架构项目搭建

nginxtomca负载均衡

vue命令行生成项目

完整的node脚手架搭建服务

Vue用webpack搭建的项目遇到的disconnected问题

SSM项目整合纪实