spring boot搭建Hello Word
一、安装与配置jdk

二、安装与配置maven
安装好maven,必须配置环境变量

通过cmd命令查询maven是否安装成功,以下是安装成功的界面

修改setting.xml的配置,制定本地仓库的路径,我将本地仓库放在D盘的LocalRepository文件夹下

三、安装idea开发工具及其配置
1、配置maven

2、配置jdk




四、搭建
1、pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>springboot</groupId>
<artifactId>springboot</artifactId>
<version>1.0-SNAPSHOT</version> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/>
</parent> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependencies> </project>
2、IndexController
package springboot.controller; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* Created by JC on 2017/2/21.
*/
@RestController
@RequestMapping(value="cont")
public class IndexController {
@RequestMapping(value = "index")
public String index()
{
return "hello"; }
}
3、Application
package springboot; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; /**
* Created by JC on 2017/2/21.
* 启动文件
*/
@SpringBootApplication
public class Application {
public static void main(String[] args)
{
SpringApplication.run(Application.class,args);
} }
4、启动Application,即可

五、问题
问题:访问项目,出现404问题,一定是路径的问题,但是一直找不到解决方法,因为初次接触springboot,终于在csdn看到解决方法

解决:出现该问题是输入URL没有映射到Controller类中,因为Controller类所在的包不在启动类所在的包下面,所以扫描不到。应该将Controller类放在启动类的下一级包中,这样的好处是,不用写任何xml,springboot会通过@SpringBootApplication自动扫描它下面的controller包,这样就能映射到啦,最好把dao、service放在启动类根包下面(谢谢csdn的大神们的解答~)


六、比较
springboot两种启动tomcat方式
1、采用springboot内嵌的tomcat启动,既上面启动Application方法
2、采用传统的tonmcat启动
springboot的相关网站:http://www.zslin.com/?cateId=3&page=1
spring boot搭建Hello Word的更多相关文章
- Set up HTTP/2 server with Spring Boot 【基于Spring boot搭建http2.0服务器】
1. Server side With spring boot, we can set up a http server easily. Restcontroller make it easier t ...
- maven 聚合工程 用spring boot 搭建 spring cloud 微服务 模块式开发项目
项目的简单介绍: 项目采用maven聚合工程 用spring boot 搭建 spring cloud的微服务 模块式开发 项目的截图: 搭建开始: 能上图 我少打字 1.首先搭建maven的聚合工程 ...
- 自我救赎 → 利用 IDEA 和 Spring Boot 搭建 SSM
前言 开心一刻 儿子读高中放学回来了,一向不管他学习的我突然来了兴趣,想看看他的学习他的状况,抄起他的数学习题看了起来,当看到 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x ...
- 手把手教你用 Spring Boot搭建一个在线文件预览系统!支持ppt、doc等多种类型文件预览
昨晚搭建环境都花了好一会时间,主要在浪费在了安装 openoffice 这个依赖环境上(Mac 需要手动安装). 然后,又一步一步功能演示,记录,调试项目,并且简单研究了一下核心代码之后才把这篇文章写 ...
- 记录一次Spring boot 搭建框架连接Mysql数据库注解事务不回滚的故障
搭建了一个新框架,使用了spring boot 替换以简化原来繁杂的spring配置,使用Spring注解管理事务,持久层使用mybatis. 连接mysql数据库完成项目的过程中发现不支持事务,因为 ...
- 使用Spring Boot搭建应用开发框架(一) —— 基础架构
Spring的简史 第一阶段:XML配置,在Spring1.x时代,使用Spring开发满眼都是xml配置的Bean,随着项目的扩大,我们需要把xml配置文件分放到不同的配置文件里,那时候需要频繁的在 ...
- Spring Boot 之Hello Word
Spring Boot官网:http://projects.spring.io/spring-boot/ 环境准备:maven 3.3.5.jdk8.Idea 1.创建maven项目工程 2.引入st ...
- Spring Boot搭建Web项目常用功能
搭建WEB项目过程中,哪些点需要注意: 1.技术选型: 前端:freemarker.vue 后端:spring boot.spring mvc 2.如何包装返回统一结构结果数据? 首先要弄清楚为什么要 ...
- 如何基于Spring Boot搭建一个完整的项目
前言 使用Spring Boot做后台项目开发也快半年了,由于之前有过基于Spring开发的项目经验,相比之下觉得Spring Boot就是天堂,开箱即用来形容是绝不为过的.在没有接触Spring B ...
随机推荐
- servlet类
一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向 ...
- python 解析 yaml文件
import yaml with open("./test.yaml") as f: x = yaml.load(f) print(x) [{'tasks': [{'yum': { ...
- conductor Workflow Metrics
Server Metrics conductor使用spectator收集指标.https://github.com/Netflix/spectator 名称 目的 标签 workflow_serve ...
- conductor任务域
任务域 任务域有助于支持任务开发.这个想法是相同的“任务定义”可以在不同的“域”中实现.域名开发人员控制的任意名称.因此,当工作流程启动时,调用者可以在工作流中的所有任务中指定哪些任务需要在特定域中运 ...
- xpath定位--绝对与相对的定位
xpath定位--绝对与相对的定位: xpath定位即为xml路径语言,它是一种用来确定xml文档中某部分位置的语言,xpath基于xml的树状结构,提供在数据结构中找寻节点的能力 xpath的相对定 ...
- DP解LCS问题模板及其优化
LCS--Longest Common Subsequence,即最长公共子序列,一般使用DP来解. 常规方法: dp[i][j]表示字符串s1前i个字符组成的字符串与s2前j个字符组成的字符串的LC ...
- 115. Distinct Subsequences (String; DP)
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...
- unity3d-ngui UIScrollView 滚动方向与滚轮相反
生成一个滚动面板之后发现滚轮向上滚,界面向下:滚轮向下界面向上.在编辑窗口里发现这个选项 本来是-2,修改成正数就可以了. http://ju.outofmemory.cn/entry/146754
- 在Eclipse中配置Maven插件
--------------------------siwuxie095 在 Eclipse 中配置 Maven 插件 ...
- centos7,Python2.7安装request包
1.安装epel扩展源:“sudo yum install epel-release” 2.安装python-pip:“sudo yum install python-pip” 3.升级pip:“su ...