SpringBoot学习笔记<一>入门与基本配置
毕业实习项目技术学习笔记
参考文献
学习视频
2小时学会Spring Boot:https://www.imooc.com/learn/767
学习资料
SpringBoot入门:https://blog.csdn.net/Phapha1996/article/details/78515865
【推荐】Spring boot <一>入门篇:https://www.cnblogs.com/ityouknow/p/5662753.html
Spring Boot中文官方文档:https://www.breakyizhan.com/springboot/3028.html
SpringBoot—访问关系型数据库—SpringData JPA:https://blog.csdn.net/phapha1996/article/details/78712597
【推荐】Spring Boot 参考指南(翻译中):
http://oopsguy.com/documents/springboot-docs/1.5.4/index.html#boot-features-spring-mvc
【推荐】Spring Boot + Jpa(Hibernate) 架构基本配置:
https://blog.csdn.net/javahighness/article/details/53055149
属性配置
spring.datasource.url:jdbc:mysql://127.0.0.1:3306
spring.datasource.username:root
spring.datasource.password:123456
spring.datasource.driver-class-name:com.mysql.jdbc
配置文件
目录:(src/main/resources)
application.properties:(src/main/resources)
server.port:8081
server.context-path:/projectname
application.yml:
server:
port: 8080
context-path: /demo
tomcat:
uri-encoding: UTF-8 spring:
datasource:
url : jdbc:mysql://xxxx:3306/xxxxx
username : xxxx
password : xxxxx
driverClassName : com.mysql.jdbc.Driver
jpa:
database : MYSQL
show-sql : true
hibernate:
ddl-auto : update
naming-strategy : org.hibernate.cfg.ImprovedNamingStrategy
properties:
hibernate:
dialect : org.hibernate.dialect.MySQL5Dialect
注解
@Controller //处理http请求,默认返回resources/templates下的html模板(view),返回参数为String类型。
@RequestMapping("/users")
public class XX{
}
@RestConroller //Spring4之后新加的注解,原来返回json需要@ResponseBody配合@Controller
public class XXX{
@Autowired
private GirlProperties girlProperties;
}
@Value("${cupSize}")
private String cupSize;
@RequestMapping(value="/user/", method=RequestMethod.GET) //配置URL映射
public String say(){
return cupSize;
}
@Component
@ConfigurationProperties(prefix="girl")
public class GirlProperties{
private String cupSize;
public String getCupSize(){
return cupSize;
}
}
Controller的使用
@PathVariable:获取url中的数据
@RequestParam:获取请求参数的值,属性有value,required,defaultValue
@GetMapping:组合注解Get
@PostMapping:组合注解Post
===========================================
【数据库】
Spring-Data-Jpa
JPA:Java Persistence API,定义了一系列对象持久化的标准,实现规范的产品有:Hibernate、TopLink等
@Entity
public class Girl{
@Id
@GenerateValue //自增
private Integer id;
private String cupSize;
//setter or getter methods
}
@Transactional //添加事务
Spring Boot 参考指南(翻译中)
SpringBoot学习笔记<一>入门与基本配置的更多相关文章
- SpringBoot学习笔记(1):配置Mybatis
SpringBoot学习笔记(1):配置Mybatis 反思:如果自己写的笔记自己都看不懂,那就不要拿出来丢人现眼! IDEA插件 Free MyBatis Plugin插件可以让我们的MyBatis ...
- SpringBoot学习笔记(一)入门简介
一.SpringBoot 入门简介 整体讲解内容概况: 1.1 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案. Spring Boot ...
- springboot学习笔记-2 一些常用的配置以及整合mybatis
一.一些常用的配置 1.1 使用没有父POM的springboot 通过添加scope=import的依赖,仍然能获取到依赖管理的好处: <dependencyManagement> &l ...
- springboot 学习笔记(二)--- properties 配置
springboot可以提供了多种方式配置properties. 一.Java System.setProperty(k, v) System.setProperty("myname&quo ...
- MongoDB 学习笔记之 入门安装和配置
下载MongoDB: 下载解压即可使用. 为了启动方便和统一管理, 在Mongo根目录下建立/data, /logs, /conf文件夹. 在conf文件夹下建立mongodb.conf 文件,基本配 ...
- springboot学习笔记:4.logback日志配置
springboot中日志组件推荐使用logback: 由于springboot内置了logback,所以可以直接在application.properties中配置:如果要功能丰富些,则配置下log ...
- Springboot学习笔记(六)-配置化注入
前言 前面写过一个Springboot学习笔记(一)-线程池的简化及使用,发现有个缺陷,打个比方,我这个线程池写在一个公用服务中,各项参数都定死了,现在有两个服务要调用它,一个服务的线程数通常很多,而 ...
- SpringBoot学习笔记(8):事物处理
SpringBoot学习笔记(8):事物处理 快速入门 在传统的JDBC事务代码开发过程中,业务代码只有一部分,大部分都是与JDBC有关的功能代码,比如数据库的获取与关闭以及事务的提交与回滚.大量的t ...
- SpringBoot学习笔记
SpringBoot个人感觉比SpringMVC还要好用的一个框架,很多注解配置可以非常灵活的在代码中运用起来: springBoot学习笔记: .一.aop: 新建一个类HttpAspect,类上添 ...
随机推荐
- Redis基础、高级特性与性能调优
本文将从Redis的基本特性入手,通过讲述Redis的数据结构和主要命令对Redis的基本能力进行直观介绍.之后概览Redis提供的高级能力,并在部署.维护.性能调优等多个方面进行更深入的介绍和指导. ...
- HTML5新特性:FileReader 和 FormData
连接在这里: HTML5新特性:FileReader 和 FormData
- Spring boot学习笔记之@SpringBootApplication注解
@SpringBootApplication(exclude = SessionAutoConfiguration.class) public class BootReactApplication { ...
- Vue中data返回对象和返回值的区别
速记:粗浅的理解是,事件的结果是影响单个组件还是多个组件.因为大部分组件是要共享的,但他们的data是私有的,所以每个组件都要return一个新的data对象 返回对象的时候 <!DOCTYPE ...
- Linux:在文件最后一列添加递增数(awk,cat函数)
假设有文件file1.txt: aa eeeee bb eeeee cc eeeee dd eeeee 先修改为: aa eeeee 1 bb eeeee 2 cc eeeee3 dd eeeee ...
- Codeforces Round #523 (Div. 2) C Multiplicity (DP)
传送门 https://www.cnblogs.com/violet-acmer/p/10005351.html 题意: 给定一数组a[],从a[ ]中除去任意个元素得到b[ ],求能形成多少“好序列 ...
- jQuery实现表格行的动态增加与删除(改进版)
之前写过一个简单的利用jQuery实现表格行的动态增加与删除的例子,有些人评论说"如果表格中是input元素,那么删除后的东西都将自动替换,这样应该是有问题的,建议楼主改进!",故 ...
- c#委托中的匿名方法和lambda表达式
一.一般委托方式 Func<int, int, int> AddMethodHander; public unName() { AddMethodHander += AddMethod; ...
- VMware for mac inside error solutions
Terminal 下执行 sudo xattr -r -d com.apple.quarantine /Applications/VMware\ Fusion.app 之后就能正常打开镜像安装虚拟机了 ...
- 非root用户sudo_ssh免密钥
非root用户sudo_ssh免密钥 目标:从服务器上ssh登陆后sudo免密钥执行相应的命令 环境介绍: 192.168.65.130 web224 # 步骤一: # 每个节点执行(不是必须,但是建 ...