springBoot学习之路
给自己加加油
这个作者很懒,什么都没留下…
展开
-
SpringBoot入门---实际开发中多个配置文件,怎么使用
在环境中有多个配置文件:application-dev.properties 开发使用application-test.properties 测试使用application-pro.properties 生产使用怎么在不同环境下切换不同的配置文件呢???通过spring.profiles.active=dev...原创 2020-10-18 16:45:51 · 335 阅读 · 0 评论 -
springBoot之注解
@PathVariable注解获取url中的参数:@RequestMapping(value = {"/hello/{id}", "hi"}, method = RequestMethod.GET) public String sayHello(@PathVariable("id") Integer id) {// return content; re...原创 2019-08-10 13:26:01 · 79 阅读 · 0 评论 -
springBoot之读取配置文件中的配置
在ymal中定义配置:cSize: Bage: 20content: "cSize: ${cSize}, age: ${age}"读取配置文件:package com.huawei.springboot1;import org.springframework.beans.factory.annotation.Autowired;import org.springframe...原创 2019-08-10 12:13:49 · 91 阅读 · 0 评论 -
springBoot的启动方式
第一种:启动main函数,推荐用法第二种:在根目录下,使用mvn spring-boot:run第三种:先mvn insatll 然后进入target目录,使用命令java -jar ******.jar原创 2019-08-06 22:59:21 · 109 阅读 · 0 评论 -
springBoot集成Mybatis
1.添加依赖<?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="...原创 2019-08-04 18:11:36 · 83 阅读 · 0 评论 -
Spring Boot之添加JSP支持
1.创建web project2.添加依赖<?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...原创 2019-08-04 16:24:19 · 111 阅读 · 0 评论 -
Spring Boot 使用freemarker
1.添加依赖<!--freemarker依赖--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId></dependenc...原创 2019-08-04 15:20:09 · 320 阅读 · 0 评论 -
全局异常捕捉
步骤: 新建一个类GlobalDefaultExceptionHandler,在class注解上@ControllerAdvice,在方法上注解@ExceptionHandler(value=Exception.class),具体代码如下:package com.huawei.exception;import org.springframework.web.bind.ann...转载 2019-07-22 00:16:08 · 230 阅读 · 0 评论 -
Spring Boot JPA-Hibernate
步骤(1)在pom中添加mysql,spring-data-jpa依赖;<!--添加mysql数据库驱动依赖包--><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId></dep...原创 2019-07-14 16:23:48 · 330 阅读 · 0 评论 -
Spring Boot JdbcTemplate
引入依赖:<!--如果已经引入了jpa,则不需要引用jdbc,即下面的依赖--> <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc...原创 2019-07-21 14:22:26 · 106 阅读 · 0 评论 -
springBoot使用thymeleaf
1.在pom中引入thymeleaf<!--引入thymeleaf依赖--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId>&l...原创 2019-07-28 23:00:40 · 120 阅读 · 0 评论 -
配置server信息
1.修改端口号spring boot默认端口是8080,如果进行更改的话,只需要修改2.修改context-path3.其他配置说明原创 2019-07-28 22:07:58 · 161 阅读 · 0 评论 -
spring boot之FastJson解析JSON数据
第一步:在pom中引入fastjson依赖:<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.15</version></dependency>第...原创 2019-06-30 22:34:27 · 384 阅读 · 0 评论 -
springBoot返回json数据
在第一篇(https://blog.csdn.net/codingToMaster/article/details/94354180)的基础上,编写实体类Student:package com.huawei;public class Student{ private int id; private String name; public int getId()...原创 2019-06-30 19:58:19 · 119 阅读 · 0 评论 -
spring boot之Hello
第一步:创建maven工程,此过程不再赘述第二部:在pom中添加依赖<?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:s...原创 2019-06-30 19:45:27 · 158 阅读 · 0 评论 -
springboot学习之springboot + devtools实现热部署
在pom中添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</op...原创 2019-07-14 09:22:14 · 96 阅读 · 0 评论