SpringBoot项目示例
一、准备工作
环境及工具:Eclipse+JDK8+Maven+SpringBoot
二、源码:
1.项目架构:
2.引入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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>blog-web</groupId>
<artifactId>blog-web</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>blog-web Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- 父级项目 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<!-- 测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- springmvc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- jpa(持久层) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency> </dependencies>
<!-- 编译 -->
<build>
<!-- 插件 -->
<plugins>
<!-- maven插件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.启动类
package com; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan; @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
public class BlogStarter {
public static void main(String[] args) {
SpringApplication.run(BlogStarter.class, args);
}
}
4.页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript"src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script> </head>
<body> </body> </html>
SpringBoot项目示例的更多相关文章
- SpringBoot项目创建与第一个SSM项目示例
本节介绍SpringBoot创建第一个示例SSM项目的完整过程,使用工具STS,与IDEA操作基本类似. 示例代码在:https://github.com/laolunsi/spring-boot-e ...
- SpringBoot入门最简单的一个项目示例
使用IDEA创建一个SpringBoot项目 1.1 打开IDEA,文件-New-Project 1.2下一步,选择版本8(根据自己安装的JDK版本来选择) 1.3 下一步后点击Web,勾选Sprin ...
- 补习系列(1)-springboot项目基础搭建课
目录 前言 一.基础结构 二.添加代码 三.应用配置 四.日志配置 五.打包部署 小结 前言 springboot 最近火的不行,目前几乎已经是 spring 家族最耀眼的项目了.抛开微服务.技术社区 ...
- Springboot 项目启动后执行某些自定义代码
Springboot 项目启动后执行某些自定义代码 Springboot给我们提供了两种"开机启动"某些方法的方式:ApplicationRunner和CommandLineRun ...
- SpringBoot入门教程(二)CentOS部署SpringBoot项目从0到1
在之前的博文<详解intellij idea搭建SpringBoot>介绍了idea搭建SpringBoot的详细过程, 并在<CentOS安装Tomcat>中介绍了Tomca ...
- linux下后台启动springboot项目
linux下后台启动springboot项目 我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn p ...
- springboot 项目中读取资源文件内容 如图片、文档文件
1 问题描述:在 springboot 项目中有时候会需要读取一些资源文件,例如 office的 docx 文档或者 png.jpg的图片.在多模块项目中资源文件需要放到启动项目的 Resources ...
- Springboot项目打包成jar运行2种方式
最近公司有个项目需要移植到SpringBoot框架上,项目里面又有许多第三方jar包,在linux服务器上最方便的就是用jar的方式来运行SpringBoot项目了,因此我研究了2种打jar包的方式, ...
- Springboot项目使用aop切面保存详细日志到ELK日志平台
上一篇讲过了将Springboot项目中logback日志插入到ELK日志平台,它只是个示例.这一篇来看一下实际使用中,我们应该怎样通过aop切面,拦截所有请求日志插入到ELK日志系统.同时,由于往往 ...
随机推荐
- JAVA程序中常用概念介绍
一.关键字.引用.直接量.变量.长量概念 1.关键字 java内部定义的java语言专用的单词,这些单词具有特殊含义,开发人员在定义自己声明的名称时,应该避开这些专用的单词.这些专用的单词也就称之为j ...
- django ModelForm在模板中显示中文
情景再现 修改ModelForm 效果
- ES query does not support [auto_generate_synonyms_phrase_query]
测试环境使用 elasticsearch-rest-high-level-client 做为基础包发起es调用出现如下异常: {"error":{"root_caus ...
- 2016蓝桥杯决赛C/C++A组第三题 打靶
题意: 小明参加X星球的打靶比赛.比赛使用电子感应计分系统.其中有一局,小明得了96分. 这局小明共打了6发子弹,没有脱靶.但望远镜看过去,只有3个弹孔.显然,有些子弹准确地穿过了前边的弹孔. 不同环 ...
- Rancher第一款Kubernetes操作系统推出
Rancher实验室推出了业界首款针对Kubernetes的轻量级操作系统k3OS.它具有极低的资源消耗,最小的操作和二级引导,极大地简化了低资源计算环境. Kubernetes操作,提高Kubern ...
- python语法技巧
目录: 7.python break continue用法 1.三元表达式 2.用列表推导式来取代map和filter 3.函数式编程 4.fluent python 阅读笔记 5.enum库用法 6 ...
- .chm无法打开问题(windows)
.chm无法打开问题,尤其是重做系统之后 C:\Windows 确保有hh.exehhctrl.ocxC:\Windows\SysWOW64 确保有itss.dll 否则百度下载hh.exehhctr ...
- c# 循环界面控件
在 Winform 开发中,窗体(Form)就像一个大容器,可以装各种各样的控件,包括 Panel控件.如果窗体是 Winform 中的最大的容器,那么 Panel控件可以算是老二,它专门用于软件界面 ...
- vue知识点散记
1.iphone5微信浏览器里的methods里貌似不兼容 test(){} 写法,只支持test:function(){} 2.v-cloak 防止双括号的闪烁 <div id=" ...
- xv6 系统调用
1. 系统调用的实现 开发程序需所有的接口在user.h中,包含两部分system call和ulib user.h中的系统接口函数在usys.S中通过汇编实现 #define SYSCALL(nam ...