搭建springboot环境
1.前戏准备:
SpringBoot核心jar包:这里直接从Spring官网下载了1.5.9版本.
jdk:jdk1.8.0_45.
maven项目管理工具:3.5版本.
tomcat:8.5版本.
本地仓库:注意settings.xml里面的设置"<localRepository>E:/SpringBoot/repository</localRepository>"红色部分代表仓库的位置.
eclipse:jee-neon3版本.

2.环境设置
1)将jdk以及maven的环境变量配置好,配好后在dos窗口进行测试:命令为java -version 和 mvn -v
JAVA_HOME:jdk所在目录
path:%JAVA_HOME%\bin
clathpath:%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
MAVEN_HOME:maven所在目录
path:%MAVEN_HOME%\bin
2)eclipse设置
jre替换成1.8版本:Windows-->Preferences-->java-->Installed JREs
maven仓库及路径设置:Windows-->Preferences-->maven-->installations 新建一个maven
:Windows-->Preferences-->maven-->user settings 路径都设为仓库的settings.xml所在路径
server:Windows-->Preferences-->server-->RunTime Environments 添加tomcat8.5
3.创建简单的maven项目
创建一个maven start项目
pom.xml配置,红色部分为重要部分
<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>com.sinosoft</groupId>
<artifactId>HelloSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HelloSpring</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
在src/main/java下新建一个Controller类
package com.sinosoft.HelloSpring;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class HelloSpring {
@RequestMapping("/app")
void index(HttpServletResponse res) throws IOException{
res.getWriter().println("Hello World!");
}
public static void main(String[] args) {
SpringApplication.run(HelloSpring.class, args);
}
}
运行main方法,在浏览器中输入http://localhost:8080/app就能得到 Hello World! 的结果
4.浏览器差异可能导致的问题
最开始用的IE8浏览器,代码及报错如下:
@RestController
@SpringBootApplication
public class HelloSpring {
@RequestMapping("/app")
String index(){
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(HelloSpring.class, args);
}
}

可是我在360浏览器上却可以正常运行并出结果,后来经查询资料,得到这是ie8不支持
所以将红色部分方法替换为
void index(HttpServletResponse res) throws IOException{
res.getWriter().println("Hello World!");
}
便可在ie8上完美运行
这只是个开始...
搭建springboot环境的更多相关文章
- Java秒杀简单设计一:搭建springboot环境
项目参考:慕课网 https://www.imooc.com/learn/587 Java秒杀 开发环境 JDK1.8.Maven.Mysql.Eclipse.SpringBoot2.0.5.myb ...
- 搭建 springboot 2.0 mybatis 读写分离 配置区分不同环境
最近公司打算使用springboot2.0, springboot支持HTTP/2,所以提前先搭建一下环境.网上很多都在springboot1.5实现的,所以还是有些差异的.接下来咱们一块看一下. 文 ...
- SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 后端篇(一): 搭建基本环境、整合 Swagger、MyBatisPlus、JSR303 以及国际化操作
相关 (1) 相关博文地址: SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 前端篇(一):搭建基本环境:https://www.cnblogs.com/l-y- ...
- SpringCloud系列二:Restful 基础架构(搭建项目环境、创建 Dept 微服务、客户端调用微服务)
1.概念:Restful 基础架构 2.具体内容 对于 Rest 基础架构实现处理是 SpringCloud 核心所在,其基本操作形式在 SpringBoot 之中已经有了明确的讲解,那么本次为 了清 ...
- (A)eclipse搭建springboot项目入门
网上许多资料都是用idea的,但是我个人用eclipse习惯了,所以就在eclipse里面自己尝试着写了一个hello. 然而项目建好后却迟迟不能访问!!!网上搜了许多资料都不靠谱! 虽然最后能看到h ...
- 搭建Springboot
这几天一直在研究IDEA上面怎么搭建一个web-mvc的SpringBoot项目,看网上的教程一步步的搭建,可是还是出现一堆的问题. 为了让大家以后少走一些弯路,我在这里分享一下我这几天研究的成果,也 ...
- 聊聊SpringBoot | 第一章:快速搭建SpringBoot第一个应用
快速搭建SpringBoot第一个应用 1.简介 本章仅介绍如何快速搭建第一个SpringBoot应用,细节内容下一章再做讲解,如果有需要,各位可以直接到Spring官网去了解. 从 Spring B ...
- Flume1 初识Flume和虚拟机搭建Flume环境
前言: 工作中需要同步日志到hdfs,以前是找运维用rsync做同步,现在一般是用flume同步数据到hdfs.以前为了工作简单看个flume的一些东西,今天下午有时间自己利用虚拟机搭建了 ...
- 搭建LNAMP环境(七)- PHP7源码安装Memcached和Memcache拓展
上一篇:搭建LNAMP环境(六)- PHP7源码安装MongoDB和MongoDB拓展 一.安装Memcached 1.yum安装libevent事件触发管理器 yum -y install libe ...
随机推荐
- 异常检测LOF
局部异常因子算法-Local Outlier Factor(LOF)在数据挖掘方面,经常需要在做特征工程和模型训练之前对数据进行清洗,剔除无效数据和异常数据.异常检测也是数据挖掘的一个方向,用于反作弊 ...
- mac电脑设置USB键盘按键方法,设置多显示屏镜像显示器的方法
mac电脑设置USB键盘按键方法,设置多显示屏镜像显示器的方法 设置多显示屏镜像显示器的方法 ==================== mac电脑复制粘贴使用command+c command+v - ...
- 【JavaScript 6连载】二、函数(工厂模式)
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"& ...
- Access is denied (user is anonymous); redirecting to authentication entry point
Access is denied (user is anonymous); redirecting to authentication entry point org.springframework. ...
- sed/awk advance
$ echo test.file [Group1]cacheways = 19 [Group2]cacheways = 19 $ ls test.sh FILE=test.file2 # Set Gr ...
- squid代理服务器安装和配置
服务器版本:centos6.5 squid版本:3.1 Squid介绍 Squid是一个缓存Internet 数据的软件,其接收用户的下载申请,并自动处理所下载的数据.当一个用户想要下载一个主页时,可 ...
- Java多线程编程作业总结
一.多线程知识总结 1.线程同步 有关创建线程的知识就不过多的叙述了.就从主要的开始讲吧,讲一下线程的同步.与操作系统中的进程同步一样,线程同样面临着资源共享的问题,怎样处理线程的资源共享是运用多线程 ...
- SCOI 2018 划水记
(此处不应有目录,省选爆零的过程得慢慢看) Day -n 一诊 说真的,在没看到“第一次诊断性考试”之前,一直以为是“一整”,真是可怕,初中教育都开始像UW中的最高祭司学习了. 感觉题目很gg.于是考 ...
- vc++读取文件属性的详细信息描述 通过读取QQ的注册表和EXE路径两种方式
转载:http://www.cnblogs.com/pythonschool/archive/2012/10/18/2729872.html // File: GetFileVersion.cpp / ...
- 解决Access查询不区分大小写问题
1.问题 比如查询用户名密码,会将所有没区分大小写的结果拿出来 2.解决 使用StrComp函数 QString execStr = QString("select * from [tabl ...