一.官网快速构建 1.maven构建项目 1.访问http://start.spring.io/ 2.选择构建工具Maven Project.Spring Boot版本2.1.1以及一些工程基本信息,可参考下图所示: 3.点击Generate Project下载项目压缩包 4.解压后,使用idea,File -> new -> Project from existing sources ->demo中的pom.xml-> Finsh,OK done! Spring Boot的基础结…
主程序类的注解 @SpringBootApplication 注解,它其实是个组合注解,源码如下: @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @Filter( type = FilterType.CU…
在前面两章 SpringBoot入门 .SpringBoot自动配置原理 的学习后,我们对如何创建一个 SpringBoot 项目.SpringBoot 的运行原理以及自动配置等都有了一定的了解.如果我们系统中也想要拥有自动配置的功能,可以自己编写一个starter (启动器),想想就觉得很酷,因为这意味着我们不仅有自己定义的自动配的功能,而且具有更通用的耦合度更低的配置. 还是以第一章开头的简单功能为例:浏览器发送 sayHello 请求,服务器接受请求并处理,响应 Hello . 首先我们看…
一.eclipse在线下载SpringBoot插件 1.help->eclipse marketplace->popular-选择spring tool suite(STS)进行下载 ​ 2.下载好之后,重启eclipse,就可以看到欢迎页,如果不放心可以:File->new->other ​ ​ 二.eclipse创建SpringBoot项目 1.File->new->other->Spring Boot->Spring Starter Project-&…
创建Springboot项目及启动器 1.创建一个简单maven项目 SpringBoot2.0以下需要使用JDK1.7 ,2.0以上使用JDK1.8 如果需要修改JDK的版本需要打开pom文件: <!-- 修改JDK版本 --> <properties> <java.version>1.8</java.version> </properties> <!-- 然后更新项目 --> 2.注入SpringBoot启动器坐标 <dep…
声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅. 一.根据官网手工搭建(http://projects.spring.io/spring-boot/#quick-start) 1.新建一个maven工程springbootfirst 2. 如果要想开发 SpringBoot 程序只需要按照官方给出的要求配置一个父 pom (spring-boot-starter-parent)和添加web开发的支持(spring-boot-starter-web)即可. <project…
Style:Mac Series:Java Since:2018-09-10 End:2018-09-10 Total Hours:1 Degree Of Diffculty:5 Degree Of Mastery:5 Practical Level:5 Desired Goal:5 Archieve Goal:3 Gerneral Evaluation:3 Writer:kingdelee Related Links: http://www.cnblogs.com/kingdelee/ 1.…
一.简介 Redis 的数据库的整合在 java 里面提供的官方工具包:jedis,所以即便你现在使用的是 SpringBoot,那么也继续使用此开发包. 二.redidTemplate操作 在 Spring 支持的 Redis 操作之中提供有一个 RedisTemplate 处理程序类,利用这个类可以非常方便的实现 Redis 的各种基本数 据操作. 1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId…
一.controller相关注解 1.@Controller 控制器,处理http请求. 2.@RespController Spring4之后新加的注解,原来返回json需要@ResponseBody和@Controller配合. 3.@RequestMapping 配置url映射,用于方法和controller类上. 4.@GetMapping 注解简写:@RequestMapping(value = "/say",method = RequestMethod.GET)等价于:@G…
一.单元测试 生成的demo里面包含spring-boot-starter-test :测试模块,包括JUnit.Hamcrest.Mockito,没有的手动加上. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> 添加测试类: @RunWith…