SpringBoot框架

SpringBoot(看这一篇就够了) Spring是一个非常优秀的轻量级框架,以IOC(控制反转)和AOP(面向切面)为思想内核,极大简化了JAVA企业级项目的开发。虽然Spring的组件代码是轻量级的,但它的配置却是重量级的。使用Spring进行项目开发需要在配置文件中写很多代码,所有这些配置都代表了开发时的损耗。除此之外,Spring项目的依赖管理也是一件耗时耗力的事情。在环境搭建时,需要分析要导入哪些库的坐标,而且还需要分析导入与之有依赖关系的其他库的坐标,一旦选错了依赖的版本,随之而来的不兼容问题就会严重阻碍项目的开发进度。比如Spri 阅读详情
AI摘要

本文详细介绍了SpringBoot的核心特性、快速入门案例以及Web开发的相关内容,包括创建SpringBoot项目、配置文件解析、SpringMVC与JSP的使用,以及MyBatis集成和RESTful实践。通过实例展示了SpringBoot如何简化配置,实现快速开发。

目录 

1.1 简介

1.2 特性

1.3 四大核心

2 springboot入门案例

2.1 SpringBoot 项目开发步骤

 2.2  创建一个 Spring MVC 的 Spring BootController 

2.3  分析

2.4 核心配置文件格式

2.5  Spring Boot 前端使用 JSP

3 SpringBoot框架Web开发

 3.1  Spring Boot 集成 MyBatis 

 3.2 DAO 的其它开发方式

 3.3 Spring Boot 事务支持

3.4  Spring Boot 下的 Spring MVC(注解)

 3.5 SpringBoot实现RESTFUL

3.6  Spring Boot 集成 Redis 

1.1 简介

springboot是spring家族中的一个全新框架,用来简化spring程序的创建和开发过程。在以往我们通过SpringMVC+Spring+Mybatis框架进行开发的时候,我们需要配置web.xml,spring配置,mybatis配置,然后整合在一起,而springboot抛弃了繁琐的xml配置过程,采用大量默认的配置来简化我们的spring开发过程。

SpringBoot化繁为简,使开发变得更加的简单迅速。

1.2 特性

  • 能够快速创建基于spring的程序
  • 能够直接使用Java main方法启动内嵌的Tomcat服务器运行springboot程序,不需要部署war包
  • 提供约定的starter POM来简化Maven配置,让Maven的配置变得简单
  • 自动化配置,根据项目的Maven依赖配置,springboot自动配置spring、springmvc等
  • 提供了程序的健康检查功能
  • 基本可以完全不使用xml配合文件,采用注解配置

1.3 四大核心

        自动配置、起步依赖、Actuator、命令行界面

2 springboot入门案例

2.1 SpringBoot 项目开发步骤

        (1)创建一个 Module,选择类型为Spring Initializr 快速构建

        (2)设置 GAV 坐标及 pom 配置信息 

 

        (3)选择 Spring Boot 版本及依赖 

        (4)设置模块名称、Content Root 路径及模块文件的目录,然后点击finish即可

        (5)项目结构如下:

        static:存放静态资源。如图片、CSS、JavaScript 等 
        templates:存放 Web 页面的模板文件 
        application.properties/application.yml 用于存放程序的各种依赖模块的配置信息,比如 服务端口,数据库连接配置等
        .gitignore:使用版本控制工具 git 的时候,设置一些忽略提交的内容 
        Application.java:SpringBoot 程序执行的入口,执行该程序中的 main 方法,启动当前SpringBoot项目。

        (6)对pom.xml文件进行解释

<?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="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
 <modelVersion>4.0.0</modelVersion> 
 <!--继承 SpringBoot 框架的一个父项目,所有自己开发的 Spring Boot 都必须的继承--> 
 <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>2.2.1.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
 </parent> 
 
 <!--当前项目的 GAV 坐标--> 
 <groupId>com.bjpowernode.springboot</groupId> 
 <artifactId>002-springboot-springmvc</artifactId> 
 <version>1.0.0</version> 
 
 <!--maven 项目名称,可以删除--> 
 <name>002-springboot-springmvc</name> 
 <!--maven 项目描述,可以删除--> 
 <description>Demo project for Spring Boot</description> 
 
 <!--maven 属性配置,可以在其它地方通过${}方式进行引用--> 
 <properties> 
     <java.version>1.8</java.version> 
 </properties> 
 
 
 <dependencies> 
 <!--SpringBoot 框架 web 项目起步依赖,通过该依赖自动关联其它依赖,不需要我们一个一个去添加
--> 
     <dependency> 
         <groupId>org.springframework.boot</groupId> 
         <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
 
 <!--SpringBoot 框架的测试起步依赖,例如:junit 测试,如果不需要的话可以删除--> 
     <dependency> 
         <groupId>org.springframework.boot</groupId> 
         <artifactId>spring-boot-starter-test</artifactId> 
         <scope>test</scope> 
         <exclusions> 
             <exclusion> 
                 <groupId>org.junit.vintage</groupId> 
                 <artifactId>junit-vintage-engine</artifactId> 
             </exclusion> 
         </exclusions> 
     </dependency> 
 </dependencies> 
 
 <build> 
     <plugins> 
         <!--SpringBoot提供的打包编译等插件--> 
         <plugin> 
             <groupId>org.springframework.boot</groupId> 
             <artifactId>spring-boot-maven-plugin</artifactId> 
         </plugin> 
     </plugins> 
 </build> 
</project> 

 2.2  创建一个 Spring MVC 的 Spring BootController 

      (1)创建SpringBootController 类

        注意:新创建的类一定要位于 Application 同级目录或者下级目录,否则 SpringBoot 加
载不到。 

package com.bjpowernode.springboot.web; 
 
import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.ResponseBody; 
 
@Controller 
public class SpringBootController { 
 
 @RequestMapping(value = "/springBoot/say") 
 public @ResponseBody String say() { 
     return "Hello,springBoot!"; 
 } 
} 

        (2)启动Application类中的main方法

        通过在控制台的输出,可以看到启动 SpringBoot 框架,会启动一个内嵌的 tomcat,端
口号为 8080,上下文根为空 。

         (3)在浏览器中输入 http://localhost:8080/springBoot/say进行访问 

2.3  分析


        (1)spring-boot-starter-parent 是一个 Springboot 的父级依赖,开发 SpringBoot 程序都需
要继承该父级项目,它用来提供相关的 Maven 默认依赖,使用它之后,常用的 jar
包依赖可以省去 version 配置 
        (2)Spring Boot 提供了一些默认的jar 包的依赖,可查看该父级依赖的 pom 文件 
        (3)如果不想使用某个默认的依赖版本,可以通过 pom.xml 文件的属性配置覆盖各个
依赖项,比如覆盖 Spring 版本: 

 <properties> 
     <spring-framework.version>5.0.0.RELEASE</ spring-framework.version > 
 </properties> 

        (4) @SpringBootApplication 注解是 Spring Boot 项目的核心注解,主要作用是开启
Spring 自动配置
,如果在 Application 类上去掉该注解,那么不会启动 SpringBoot程序 
        (5)main 方法是一个标准的 Java 程序的 main 方法,是boot项目启动运行的入口
        (6)@Controller 及 @ResponseBody 依然是我们之前的 Spring MVC,因为 Spring Boot
的里面依然是使用我们的 Spring MVC + Spring + MyBatis 等框架 

2.4 核心配置文件格式

        (1).properties 文件(默认采用该文件) 

通过修改 application.properties 配置文件,修改默认 tomcat 端口号及项目上下文件根:

#设置内嵌 Tomcat 端口号 
server.port=9090 
 
#配置项目上下文根 
server.servlet.context-path=/003-springboot-port-context-path 

 页面显示结果:

        (2) .yml 文件 :

        项目名称:004-springboot-yml

        yml 是一种 yaml 格式的配置文件,主要采用一定的空格、换行等格式排版进行配置。它能够直观的被计算机识别数据序列化格式,容易被人类阅读,yaml 类似于 xml,但是语法比 xml 简洁很多,值与前面的冒号配置项必须要有一个空格, yml 后缀也可以使用 yaml 后缀 。

        注意:当两种格式配置文件同时存在时,使用的是.properties 配置文件。

        (3)多环境配置(.properties方式)

        在实际开发的过程中,我们的项目会经历很多的阶段(开发->测试->上线),每个阶段
的配置也会不同,例如:端口、上下文根、数据库等,那么这个时候为了方便在不同的环境
之间切换,SpringBoot 提供了多环境配置
,具体步骤如下 :

        项目名称:005-springboot-multi-environment 

为每个环境创建一个配置文件,命名必须为 application-环境标识.properties|yml

 application-dev.properties 

#开发环境

#设置内嵌 Tomcat 默认端口号 
server.port=8080 
 
#设置项目的上下文根 
server.servlet.context-path=/005-springboot-multi-environment-dev 

application-product.properties

#生产环境 
 
#配置内嵌 Tomcat 默认端口号 
server.port=80 
 
#配置项目上下文根 
server.servlet.context-path=/005-springboot-multi-environment-product 

application-test.properties

#测试环境 
 
#配置内嵌 Tomcat 端口号 
server.port=8081 
 
#配置项目的上下文根 
server.servlet.context-path=/005-springboot-multi-environment-test 

 在总配置文件 application.properties 进行环境的激活

#SpringBoot 的总配置文件 
 
#激活开发环境 
#spring.profiles.active=dev 
 
#激活测试环境 
#spring.profiles.active=test 
 
#激活生产环境 
spring.profiles.active=product 

        (4)多环境配置(.yml方式)

 application-dev.yml

#设置开发环境配置 
 
server: 
 port: 8080 #设置 Tomcat 内嵌端口号 
 servlet: 
  context-path: /dev #设置上下文根 

application-product.yml

#设置生产环境配置 
 
server: 
 port: 80 
 servlet: 
  context-path: /product 

application-test.yml

#设置测试环境配置 
 
server: 
 port: 9090 
 servlet: 
  context-path: /test

 在总配置文件 application.yml进行环境的激活

#springboot 总配置文件 
 
#激活开发环境 
#spring: 
# profiles: 
#  active: dev 
 
 
#激活测试环境 
#spring: 
# profiles: 
#  active: test 
 
#激活生产环境 
spring: 
 profiles: 
  active: product 

        (5)Spring Boot 自定义配置

        在 SpringBoot 的核心配置文件中,除了使用内置的配置项之外,我们还可以在自定义配
置,然后采用如下注解去读取配置的属性值:

        (A)@Value注解 用于逐个读取application.properties中的配置

        案例演示:

       (1) 在核心配置文件 applicatin.properties 中,添加两个自定义配置项 school.name 和
website。在 IDEA 中可以看到这两个属性不能被 SpringBoot 识别,背景是桔色的 :

.properties方式

 .yml方式

#设置端口号及上下文根 
server: 
 port: 9090 
 servlet: 
  context-path: / 
 
school: 
 name: ssm 
websit: http://www.baidu.com 

        (2)在 SpringBootController 中定义属性,并使用@Value 注解或者自定义配置值,并对其方法进行测试

@Controller 
public class SpringBootController { 
 
 @Value("${school.name}") 
 private String schoolName; 
 
 @Value("${websit}") 
 private String websit; 
 
 @RequestMapping(value = "/springBoot/config") 
 public @ResponseBody String say() { 
 return schoolName + "------" + websit; 
 } 
} 

        (3)重新运行 Application,在浏览器中进行测试 

         (B)@ConfigurationProperties

        作用:将整个文件映射成一个对象,用于自定义配置项比较多的情况 。

        案例演示:

        (1)在 com.abc.springboot.config 包下创建 ConfigInfo 类,并为该类加上 Component 和
ConfigurationProperties 注解,并在 ConfigurationProperties 注解中添加属性 prefix,可以区分同名配置 。

@Data
@Component 
@ConfigurationProperties(prefix = "school") 
public class ConfigInfo { 
 
 private String name; 
 
 private String websit; 
} 

        (2)application.properties 配置文件

#设置内嵌 Tomcat 端口号 
server.port=9090 
 
#设置上下文根 
server.servlet.context-path=/config 
 
school.name=ssm 
school.websit=http://www.baidu.com 

        (3)在 SpringBootController 中注入 ConfigInfo 配置类 

@Autowired 
private ConfigInfo configInfo; 

        (4)修改 SpringBootController 类中的测试方法

@RequestMapping(value = "/springBoot/config") 
public @ResponseBody String say() { 
 return configInfo.getName() + "=======" + configInfo.getWebsit(); 
} 

        (5)重新运行 Application,在浏览器中进行测试 

         (C)警告解决

        在 ConfigInfo 类中使用了 ConfigurationProperties 注解后,IDEA 会出现一个警告,不影响程序的执行。

        点击 open documentnation 跳转到网页,在网页中提示需要加一个依赖,我们将这
个依赖拷贝,粘贴到 pom.xml 文件中 即可。

<!--解决使用@ConfigurationProperties 注解出现警告问题--> 
<dependency> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-configuration-processor</artifactId> 
  <optional>true</optional> 
</dependency> 

        (D)中文乱码

    如果在 SpringBoot 核心配置文件中有中文信息,会出现乱码: 

  • 一般在配置文件中,不建议出现中文(注释除外) 
  • 如果出现中文,可以先转化为 ASCII 码 

2.5  Spring Boot 前端使用 JSP

         (1)在 pom.xml 文件中配置以下依赖项

<!--引入 Spring Boot 内嵌的 Tomcat 对 JSP 的解析包,不加解析不了 jsp 页面--> 
<!--如果只是使用 JSP 页面,可以只添加该依赖--> 
<dependency> 
 <groupId>org.apache.tomcat.embed</groupId> 
 <artifactId>tomcat-embed-jasper</artifactId> 
</dependency> 
 
<!--如果要使用 servlet 必须添加该以下两个依赖--> 
<!-- servlet 依赖的 jar 包--> 
<dependency> 
 <groupId>javax.servlet</groupId> 
 <artifactId>javax.servlet-api</artifactId> 
</dependency> 
<dependency> 
 <groupId>javax.servlet.jsp</groupId> 
 <artifactId>javax.servlet.jsp-api</artifactId> 
 <version>2.3.1</version> 
</dependency> 
 
<!--如果使用 JSTL 必须添加该依赖--> 
<!--jstl 标签依赖的 jar 包 start--> 
<dependency> 
 <groupId>javax.servlet</groupId> 
 <artifactId>jstl</artifactId> 
</dependency> 

        (2)在 pom.xml 的 build 标签中要配置以下信息 
        SpringBoot 要求 jsp 文件必须编译到指定的 META-INF/resources 目录下才能访问,否则
访问不到
。其实官方已经更建议使用模板技术。

<!-- 
 SpringBoot 要求 jsp 文件必须编译到指定的 META-INF/resources 目录下才能访问,否则访问
不到。 
 其它官方已经建议使用模版技术
--> 
<resources> 
 <resource> 
     <!--源文件位置--> 
     <directory>src/main/webapp</directory> 
     <!--指定编译到 META-INF/resources,该目录不能随便写--> 
     <targetPath>META-INF/resources</targetPath> 
     <!--指定要把哪些文件编译进去,**表示 webapp 目录及子目录,*.*表示所有文件--> 
     <includes> 
         <include>**/*.*</include> 
     </includes> 
 </resource> 
</resources> 

        (3)在 application.properties 文件配置 Spring MVC 的视图展示为jsp,这里相当于 Spring MVC 的配置。

#SpringBoot 核心配置文件 
#指定内嵌 Tomcat 端口号 
server.port=8090 
 
#配置 SpringMVC 视图解析器 
#其中:/ 表示目录为 src/main/webapp 
spring.mvc.view.prefix=/ 
spring.mvc.view.suffix=.jsp 

        (4)在 com.abc.springboot.controller 包下创建 JspController 类

@Controller 
public class SpringBootController { 
 
 @RequestMapping(value = "/springBoot/jsp") 
 public String jsp(Model model) { 
 
     model.addAttribute("data","SpringBoot 前端使用 JSP 页面!"); 
 
 return "index"; 
 } 
} 

        (5)在 src/main 下创建一个 webapp 目录,然后在该目录下新建index.jsp 页面 

        注意: 如果在webapp目录下右键,没有创建jsp的选项,可以在Project Structure中指定webapp为 Web Resource Directory 。

         (6)在 index.jsp 中获取 Controller 传递过来的数据 

         (7)重新运行 Application,通过浏览器访问测试 

3 SpringBoot框架Web开发

通过实际代码案例进行梳理:

 3.1  Spring Boot 集成 MyBatis 

通过 SpringBoot +MyBatis 实现对数据库学生表的查询操作的实现步骤:

(1)创建新的数据库springboot并向表中插入数据

(2)创建一个新的 SpringBoot 的 Module 

        创建项目的过程省略

(3)在 pom.xml 中添加相关 jar 依赖 

<!--MyBatis 整合 SpringBoot 的起步依赖--> 
<dependency> 
 <groupId>org.mybatis.spring.boot</groupId> 
 <artifactId>mybatis-spring-boot-starter</artifactId> 
 <version>2.0.0</version> 
</dependency> 

<!--MySQL 的驱动依赖--> 
<dependency> 
 <groupId>mysql</groupId> 
 <artifactId>mysql-connector-java</artifactId> 
</dependency> 

(4)在 Springboot 的核心配置文件 application.properties 中配置数据源 

#配置内嵌 Tomcat 端口号 
server.port=9090 
 
#配置项目上下文根 
server.servlet.context-path=/010-springboot-web-mybatis 
 
#配置数据库的连接信息 
#注意这里的驱动类有变化 
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8 
 
spring.datasource.username=root 
spring.datasource.password=root

(5)开发代码(代码生成器)

使用 Mybatis 反向工程生成接口、映射文件以及实体 bean,具体步骤参见附录 1

         (A)在 web 包下创建 StudentController 并编写代码

@Controller 
public class StudentController { 
 
 @Autowired 
 private StudentService studentService; 
 
 @RequestMapping(value = "/springBoot/student") 
 public @ResponseBody Object student() { 
 
 Student student = studentService.queryStudentById(1); 
 
 return student; 
 } 
} 

        (B)在 service 包下创建 service 接口并编写代码 

public interface StudentService { 
 
 /** 
 * 根据学生标识获取学生详情 
 * @param id 
 * @return 
 */ 
 Student queryStudentById(Integer id); 
}

        (C)在 service.impl 包下创建 service 接口并编写代码

@Service 
public class StudentServiceImpl implements StudentService { 
 

 @Autowired 
 private StudentMapper studentMapper; 
 
 @Override 
 public Student queryStudentById(Integer id) { 
 return studentMapper.selectByPrimaryKey(id); 
 } 
} 

        (D)如果在 web 中导入 service 存在报错,可以尝试进行如下配置解决 

        (E) 在 Mybatis 反向工程生成的 StudentMapper 接口上加一个 Mapper 注解 
@Mapper 作用:mybatis 自动扫描数据持久层的映射文件及 DAO 接口的关系

@Mapper 
public interface StudentMapper { 
}

        (F)默认情况下,Mybatis 的 xml 映射文件不会编译到 target 的 class 目录下,所
以我们需要在 pom.xml 文件中配置 resource 。

<resources> 
 <resource> 
 <directory>src/main/java</directory> 
 <includes> 
     <include>**/*.xml</include> 
 </includes> 
 </resource> 
</resources>

        (G)启动 Application 应用,浏览器访问测试运行

 3.2 DAO 的其它开发方式

方式一:

(A)注释掉 StudentMapper 接口上的@Mapper 注解 

(B)在运行的主类上添加注解包扫描MapperScan("com.abc.springboot.mapper") 

@SpringBootApplication 
@MapperScan("com.abc.springboot.mapper") 
public class Application { 

或

@SpringBootApplication 
//Mybatis 提供的注解:扫描数据持久层的 mapper 映谢配置文件,DAO 接口上就不用加@Mapper 
//basePackages 通常指定到数据持久层包即可 
@MapperScan(basePackages = "com.abc.springboot.mapper") 
public class Application { 

方式二:

        因为 SpringBoot 不能自动编译接口映射的 xml 文件,还需要手动在 pom 文件中指定,
所以有的公司直接将映射文件直接放到 resources 目录下 ,在 resources 目录下新建目录 mapper 存放映射文件,将 StudentMapper.xml 文件移到resources/mapper 目录下:

        在 application.properties 配置文件中指定映射文件的位置,这个配置只有接口和映
射文件不在同一个包的情况下,才需要指定:

# 指定 Mybatis 映射文件的路径 
mybatis.mapper-locations=classpath:mapper/*.xml 

 3.3 Spring Boot 事务支持

springboot事务底层依然采用的是 Spring 本身提供的事务管理。

  • 在入口类中使用注解@EnableTransactionManagement开启事务支持
  • 在访问数据库的service方法上添加注解@Transactional即可

       在上述案例的基础上,通过 SpringBoot +MyBatis 实现对数据库学生表的更新操作,在 service 层的方法中构建异常,查看事务是否生效:

        (1)在 StudentController 中添加更新学生的方法

@RequestMapping(value = "/springboot/modify") 
public @ResponseBody Object modifyStudent() { 
 
 int count = 0; 
 try { 
 Student student = new Student(); 
 student.setId(1); 
 student.setName("Jack"); 
 student.setAge(33); 
 count = studentService.modifyStudentById(student); 
 } catch (Exception e) { 
 e.printStackTrace(); 
 return "fail"; 
 } 
 
 return count; 
} 

        (2)在 StudentService 接口中添加更新学生方法

int modifyStudentById(Student student); 

        (3)在 StudentServiceImpl 接口实现类中对更新学生方法进行实现,并构建一个异常,同时在该方法上加@Transactional 注解。

@Override 
@Transactional //添加此注解说明该方法添加的事务管理 
public int update(Student student) { 
 
 int updateCount = studentMapper.updateByPrimaryKeySelective(student); 
 
 System.out.println("更新结果:" + updateCount); 
 
 //在此构造一个除数为 0 的异常,测试事务是否起作用 
 int a = 10/0; 
 
 return updateCount; 
} 

        (4)在Application类上加@EnableTransactionManagement开启事务支持。

@EnableTransactionManagement 可选,但是业务方法上必须添加@Transactional 事务才生效

@SpringBootApplication 
@MapperScan(basePackages = "com.abc.springboot.mapper") 
@EnableTransactionManagement //开启事务支持(可选项,但@Transactional 必须添加) 
public class Application { 

3.4  Spring Boot 下的 Spring MVC(注解)

springboot下的springMVC主要有以下注解:

        (1)@Controller:Spring MVC 的注解,处理 http 请求

        (2)@RestController :@Controller 与@ResponseBody 的组合注解 

        如果一个 Controller 类添加了@RestController,那么该 Controller 类下的所有方法都相当
于添加了@ResponseBody 注解 ,用于返回字符串或json数据。

创建 MyRestController 类,演示@RestController 替代@Controller + @ResponseBody

@RestController 
public class MyRestController { 
 @Autowired 
 private StudentService studentService; 
 
 @RequestMapping("/boot/stu") 
 public Object stu(){ 
 return studentService.getStudentById(1); 
 } 
} 

        (3)@RequestMapping:支持 Get 请求,也支持 Post 请求 。
        (4)@GetMapping :只支持 Get 请求,主要用于查询操作。

        (5)@PostMapping:只支持Post请求,主要用于新增数据。

        (6)@PutMapping:只支持put请求,主要用于修改数据

        (7)@DeleteMapping:只支持delete请求,通常用与删除数据

        (8)综合案例:

(A)创建一个 MVCController,里面使用上面介绍的各种注解接收不同的请求 

//RestController 注解相当于加了给方法加了@ResponseBody 注解,所以是不能跳转页面的,只能返回字符串或者 json 数据 
@RestController 
public class MVCController { 
 
 @GetMapping(value = "/query") 
 public String get() { 
 return "@GetMapping 注解,通常查询时使用"; 
 } 
 
 
 @PostMapping(value = "/add") 
 public String add() { 
 return "@PostMapping 注解,通常新增时使用"; 
 } 
 
 @PutMapping(value = "/modify") 
 public String modify() { 
 return "@PutMapping 注解,通常更新数据时使用"; 
 } 
 
 @DeleteMapping(value = "/remove") 
 public String remove() { 
 return "@DeleteMapping 注解,通常删除数据时使用"; 
 } 
} 

(B)启动应用,在浏览器中输入不同的请求进行测试

 (C)结合POSTMan工具测试其他请求类型

 3.5 SpringBoot实现RESTFUL

        (1)简介

        它是一种互联网软件设计的风格,它只是提出了一组客户端和服务器交互时的架构理念和设计原则,基于这种理念和原则设计的接口可以更简洁,更有层次。

比如我们要访问一个 http 接口:http://localhost:8080/boot/order?id=1021&status=1 
采用 RESTFul 风格则 http 地址为:http://localhost:8080/boot/order/1021/1 

        (2)开发RESTFUL,主要用到以下注解:

  • @PathVariable :获取 url 中的数据,该注解是实现 RESTFul 最主要的一个注解
  •  @PostMapping :接收和处理post方式的请求
  • @DeleteMapping:接收delete方式的请求,可以用GetMapping代替
  • @PutMapping :接收put方式的请求,可以用 PostMapping 代替 
  • @GetMapping :接收get方式请求

    (3)案例:使用 RESTful 风格模拟实现对学生的增删改查操作

该项目集成了 MyBatis、spring、SpringMVC,通过模拟实现对学生的增删改查操作

pom.xml文件

<dependencies> 
 <!--SpringBoot 框架 web 项目起步依赖--> 
 <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
 </dependency> 
 
 <!--MyBatis 集成 SpringBoot 框架起步依赖--> 
 <dependency> 
     <groupId>org.mybatis.spring.boot</groupId> 
     <artifactId>mybatis-spring-boot-starter</artifactId> 
     <version>2.0.1</version> 
 </dependency> 
 <!--MySQL 驱动--> 
 <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
 </dependency> 
</dependencies> 
 
<build> 
 <!--指定配置资源的位置--> 
 <resources> 
     <resource> 
         <directory>src/main/java</directory> 
         <includes> 
             <include>**/*.xml</include> 
         </includes> 
     </resource> 
 </resources> 
 
 <plugins> 
     <!--mybatis 代码自动生成插件--> 
     <plugin> 
         <groupId>org.mybatis.generator</groupId> 
         <artifactId>mybatis-generator-maven-plugin</artifactId> 
         <version>1.3.6</version> 
         <configuration> 
             <!--配置文件的位置--> 
             <configurationFile>GeneratorMapper.xml</configurationFile> 
             <verbose>true</verbose> 
             <overwrite>true</overwrite> 
         </configuration> 
     </plugin> 
 
     <plugin> 
         <groupId>org.springframework.boot</groupId> 
         <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
 </plugins> 
</build> 

application. properties核心配置文件

#配置内嵌 Tomcat 端口号 
server.port=8090 
 
#配置项目上下文根 
server.servlet.context-path=/
 
#配置数据库的连接信息 
#注意这里的驱动类有变化 
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8 
 
spring.datasource.username=root 
spring.datasource.password=root

通过逆向工程生成 DAO

创建 RESTfulController

@RestController 
public class RESTfulController { 
 
 /** 
 * 添加学生 
 * 请求地址:
http://localhost:9090/014-springboot-restful/springBoot/student/wangpeng/23 
 * 请求方式:POST 
 * @param name 
 * @param age 
 * @return 
 */ 
 @PostMapping(value = "/springBoot/student/{name}/{age}") 
 public Object addStudent(@PathVariable("name") String name, @PathVariable("age") Integer age) { 
 
 Map<String,Object> retMap = new HashMap<String, Object>(); 
 retMap.put("name",name); 
 retMap.put("age",age); 
 
 
 return retMap; 
 } 
 
 /** 
 * 删除学生 
 * 请求地址:
http://localhost:9090/014-springboot-restful/springBoot/student/1 
 * 请求方式:Delete 
 * @param id 
 * @return 
 */ 
 @DeleteMapping(value = "/springBoot/student/{id}") 
 public Object removeStudent(@PathVariable("id") Integer id) { 
 
 return "删除的学生 id 为:" + id; 
 } 
 
 /** 
 * 修改学生信息 
 * 请求地址:
http://localhost:9090/014-springboot-restful/springBoot/student/2 
 * 请求方式:Put 
 * @param id 
 * @return 
 */ 
 @PutMapping(value = "/springBoot/student/{id}") 
 public Object modifyStudent(@PathVariable("id") Integer id) { 
 
 return "修改学生的 id 为" + id; 
 } 
 
 @GetMapping(value = "/springBoot/student/{id}") 
 public Object queryStudent(@PathVariable("id") Integer id) { 
 
 return "查询学生的 id 为" + id; 
 } 
} 

使用 Postman 模拟发送请求,进行测试 :

 

 

 

         (4)请求冲突的问题

           解决方案:<1>修改路径     <2>修改请求方式

创建 RESTfulController 类,结合 Postman 进行测试说明 :

@RestController 
public class RESTfulController { 
 
 /** 
 * id:订单标识 
 * status:订单状态 
 * 请求路径:
http://localhost:9090/015-springboot-restful-url-conflict/springBoot/orde
r/1/1001 
 * @param id 
 * @param status 
 * @return 
 */ 
 @GetMapping(value = "/springBoot/order/{id}/{status}") 
 public Object queryOrder(@PathVariable("id") Integer id, @PathVariable("status") Integer status) { 
 
 Map<String,Object> map = new HashMap<String,Object>(); 
 
 map.put("id",id); 
 map.put("status",status); 
 
 return map; 
 } 
 
 /** 
 * id:订单标识 
 * status:订单状态 
 * 请求路径:
http://localhost:9090/015-springboot-restful-url-conflict/springBoot/1/or
der/1001 
 * @param id 
 * @param status 
 
 * @return 
 */ 
 @GetMapping(value = "/springBoot/{id}/order/{status}") 
 public Object queryOrder1(@PathVariable("id") Integer id, @PathVariable("status") Integer status) { 
 Map<String,Object> map = new HashMap<String,Object>(); 
 
 map.put("id",id); 
 map.put("status",status); 
 
 return map; 
 } 
 
 /** 
 * id:订单标识 
 * status:订单状态 
 * 请求路径:
http://localhost:9090/015-springboot-restful-url-conflict/springBoot/1001
/order/1 
 * @param id 
 * @param status 
 * @return 
 */ 
 @GetMapping(value = "/springBoot/{status}/order/{id}") 
 public Object queryOrder2(@PathVariable("id") Integer id, 
 @PathVariable("status") Integer status) { 
 Map<String,Object> map = new HashMap<String,Object>(); 
 
 map.put("id",id); 
 map.put("status",status); 
 
 return map; 
 } 
 
 /** 
 * id:订单标识 
 * status:订单状态 
 * 请求路径:
http://localhost:9090/015-springboot-restful-url-conflict/springBoot/1001
/order/1 
 * @param id 
 * @param status 
 * @return 
 */ 
 

 @PostMapping(value = "/springBoot/{status}/order/{id}") 
 public Object queryOrder3(@PathVariable("id") Integer id,  @PathVariable("status") Integer status) { 
 Map<String,Object> map = new HashMap<String,Object>(); 
 
 map.put("id",id); 
 map.put("status",status); 
 
 return map; 
 } 
 
 
 
 
 /** 
 * query1 和 query2 两个请求路径会发生请求路径冲突问题 
 * query3 与 query1 和 query2 发生请求冲突 
 * 注意:虽然两个路径写法改变了,但是由于传递的两个参数都是 int 值,所以不知道该交给
哪个请求进行处理 
 * 就会出现匹配模糊不清的异常,所以要想解决冲突,有两种方式: 
 * 1.修改请求路径 
 * 2.修改请求方式 
 */ 
} 

        (5)RESTful 原则

  • 增 post 请求、删 delete 请求、改 put 请求、查 get 请求 
  • 请求路径不要出现动词:

        

  •  分页、排序等操作,不需要使用斜杠传参数

        

3.6  Spring Boot 集成 Redis 

        完善根据学生 id 查询学生的功能:先从 redis 缓存中查找,如果找不到,再从数据库中
查找,然后放到 redis 缓存中。

具体实现步骤:

(A)首先通过 MyBatis 逆向工程生成实体 bean 和数据持久层 :

(B)在 pom.xml 文件中添加 redis 依赖

<!-- 加载 spring boot redis 包 --> 
<dependency> 
 <groupId>org.springframework.boot</groupId> 
 <artifactId>spring-boot-starter-data-redis</artifactId> 
</dependency> 

 (C)Spring Boot 核心配置文件application.properties 如下:

#配置内嵌 Tomcat 端口号 
server.port=9090 
 
#配置项目上下文根 
server.servlet.context-path=/016-springboot-redis 
 
#配置连接 MySQL 数据库信息 
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springboot?useUnicode=true&characterEncoding=UTF8&useJDBCCompliantTimezoneShift=true&useLegacyDa
tetimeCode=false&serverTimezone=GMT%2B8 
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 
spring.datasource.username=root 
spring.datasource.password=root
 
#配置 redis 连接信息 
spring.redis.host=127.0.0.1 
spring.redis.port=6379 
#spring.redis.password=root

(D)启动redis服务

 (E)RedisController类

@RestController 
public class RedisController { 
 
 @Autowired 
 private StudentService studentService; 
 
 /** 
 * 请求地址:
http://localhost:9090/016-springboot-redis//springboot/allStudentCount 
 * @param request 
 * @return 
 */ 
 @GetMapping(value = "/springboot/allStudentCount") 
 public Object allStudentCount(HttpServletRequest request) { 
 
 Long allStudentCount = studentService.queryAllStudentCount(); 
 
 return "学生总人数:" + allStudentCount; 
 } 
} 

(F)StudentService 接口

public interface StudentService { 
 
 /** 
 * 获取学生总人数 
 * @return 
 */ 
 Long queryAllStudentCount(); 
} 

(G)在 StudentServiceImpl 中注入 RedisTemplate,并编写根据 id获取学生的方法

        配置了上面的步骤,Spring Boot 将自动配置 RedisTemplate,在需要操作 redis 的类中注入 redisTemplate 即可。 
        注意:Spring Boot 帮我们注入 RedisTemplate 类,泛型里面只能写 <String, String>、<Object, Object>或者什么都不写。

@Service 
public class StudentServiceImpl implements StudentService { 
 
 @Autowired 
 private StudentMapper studentMapper; 
 
 @Autowired 
 private RedisTemplate<Object,Object> redisTemplate; 
 
 @Override 
 public Long queryAllStudentCount() { 
 
 //设置 redisTemplate 对象 key 的序列化方式 
 redisTemplate.setKeySerializer(new StringRedisSerializer()); 
 
 //从 redis 缓存中获取总人数 
 Long allStudentCount = (Long) redisTemplate.opsForValue().get("allStudentCount"); 
 //判断是否为空 
 if ( allStudentCount==null) { 
 //去数据库查询,并存放到 redis 缓存中 
 
 allStudentCount = studentMapper.selectAllStudentCount(); 
 
redisTemplate.opsForValue().set("allStudentCount",allStudentCount,15,TimeUnit.SECONDS); 
 } 
 return allStudentCount; 
 } 
} 

(H)StudentMapper 接口

@Mapper
public interface StudentMapper {
 /** 
 * 获取学生总人数 
 * @return 
 */ 
 Long selectAllStudentCount(); 
}

(I)StudentMapper 映射文件 

<!--获取学生总人数--> 
<select id="selectAllStudentCount" resultType="java.lang.Long"> 
 select count(*) from  t_student 
</select> 

(J)启动类 Application

在 SpringBoot 启动类上添加扫描数据持久层的注解并指定扫描包:

@SpringBootApplication 
@MapperScan(basePackages = "com.abc.springboot.mapper")//扫描数据持久层 
public class Application { 
 
 public static void main(String[] args) { 
 SpringApplication.run(Application.class, args); 
 } 
 
} 

(K)让 Student 类实现序列化接口(可选)

在类名上 Alt + 回车,如果没有提示生成序列化 id,那么需要做如下的配置 :

 (L)启动 SpringBoot 应用,访问测试

SpringBoot详解 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。...... 阅读详情

相关推荐

SpringBoot介绍。

SpringBoot` 是由Pivotal团队提供的全新框架,其设计目的是用来简化Spring应用的初始搭建以及开发过程。原始 `Spring` 环境搭建和开发存在以下问:● 配置繁琐● 依赖设置繁琐`SpringBoot` 程序优点恰巧就是针对 `Spring` 的缺点● 自动配置。这个是用来解决 `Spring` 程序配置繁琐的问题● 起步依赖。这个是用来解决 `Spring` 程序依赖设置繁琐的问题● 辅助功能(内置服务器,...)。

yzh2776680982的博客 8292

Spring Boot+Bootstrap开发小而完整web项目

跟着本课程Demo完整的动手写一次,会发现你已经可以直接利用Spring Boot上手中小型web项目了。  Spring Boot框架是现在比较热门的微服务框架,很多软件公司都在使用,本课程涵盖Spring Boot和Bootstrap较为多面的知识点,针对Spring Boot开发web项目中每个阶段的关键内容和痛点,一步步进行条理清晰的讲解,学员在听课过程中建立起自己较为完备的前端、后端知识体系,具备较好的项目开展能力和自信。 课程特点是不炫技、条理清晰、生动浅显、化繁为简,每个章节都会围绕Spring Boot、Bootstrap的知识点“是什么、有什么用、怎么用”展开,并根据精心准备的简洁清晰的示例进行讲解。   学完该套课程后,可以很快上手Spring Boot实战开发,一个人就能完成一个基于Spring Boot+Bootstrap的完整WEB项目!  

SpringBoot —— 日志框架

SpringBoot —— 日志框架 一、类比 JDBC—数据库驱动的架构(门面设计模式) 1. 在我们开发应用的场景中,需要用到很多jar包,而这些包又有自己的日志框架 那么,如何实现便捷的切换日志记录框架? 解决: 首先,写了一个统一的接口层 SLF4J,作为日志门面(日志的一个抽象层),例如:logging-abstract.jar; 想用哪个日志框架(实现了日志门面接口),就给项目中导入具体的日志实现就行了; 如果不能直接作为 SLF4J 的日志实现,例如:log4j,可以在中间使用一个适配层

weixin_44730681的博客 868

springboot基础篇(快速入门+要点总结)

本文详细的介绍了springboot的来源以及和spring的关系,和为什么使用springboot,然后介绍了两种搭建springboot项目的方法,以及热部署,properties配置文件的使用,在最后对于日志做出了详细的说明和用法。

zhaolk的博客 6万+

【医学影像】超声(UltraSound)影像的增强与目标检测

文章目录1 综述1.1 超声发展简史1.2 超声类型2 超声影像的去噪与增强2.1 各向异性扩散去噪模型2.2 色彩恢复的视网膜增强算法SSR和MSR2.3 MSRCR增强算法(基于MSR算法改进版)2.4 参考文献3 超声影像的目标识别3.1 基于跨模态数据迁移进行DL训练3.2 参考文献 1 综述 因工作需要,最近调研了超声(UltraSound)影像的相关知识,包含超声类型、超声影像的去噪和增强,目标检测等,并对相关资料文献进行梳理整合。 本人另外一篇博文主要讲了UltraSound 影像与CT/MR

muyijames的博客 1万+

DDR5内存Training全解析:从信号完整性到CS训练模式的实战指南

本文深入解析了DDR5内存Training的全过程,从信号完整性挑战到CS训练模式(CSTM)的实战应用。文章详细阐述了Training在DDR5高频时代的关键作用,对比了In-Band与OOB两种架构,并拆解了Intel MRC的核心训练步骤,为硬件与固件工程师提供了诊断与优化系统稳定性的实用指南。

weixin_29252171的博客 1044

Spring Boot |SpringBoot的日志框架及配置

文章目录一、常用的日志框架1.1 日志门面1.2 日志实现1.3 Spring Boot的日志框架选择二、SLF4j的使用2.1 SLF4j使用原理2.2 统一日志管理三、SpringBoot日志关系 一、常用的日志框架 市场上存在非常多的日志框架,分为日志门面(日志的抽象层)和日志实现。 1.1 日志门面 JUL(java.util.logging) JCL(ApacheCommons Lo...

匿名攻城狮 1841

Oracle19c安装,基本配置教程(超详细)

安装有出错的风险,卸载也是比较麻烦的,所以先提前设置一个还原点,在windows中的步骤如下,如果对自己有信心,可以直接跳过该部分开始安装oracle在设置中进入创建还原点的界面开始创建还原点上面已经成功创建了还原点,如果安装oracle时出现问题,自己也无法解决,恢复到安装之前即可,恢复步骤如下经过上面的步骤,Oracle我们就能够正常使用了,我们就使用自己在sql plus里面创建的账号即可,创建的表会默认存放在我们自己创建的表空间里面。

秃头披风侠的博客 7万+

SpringBoot框架简介

SpringBoot是由Pivotal团队提供的基于Spring的全新框架。Spring Boot是一个用于快速构建基于Spring框架的Java应用程序的开源框架。它旨在简化Spring应用程序的开发过程,通过提供一种约定优于配置的方式,减少开发者对配置的需求,从而提高开发效率。SpringBoot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式,简省了繁重的配置,并提供了各种启动器,使开发者能快速上手。

2302_80864660的博客 4万+

使用 Wireshark 进行计算机网络协议分析

文章目录实验前准备一、Wireshark抓包示例二、Wireshark实作1、数据链路层实作一 熟悉Ethernet帧结构实作二 了解子网内/外通信时的 MAC 地址实作三 掌握 ARP 解析过程2、网络层实作一 熟悉 IP 包结构实作二 IP 包的分段与重组实作三 考察 TTL 事件3、传输层实作一 熟悉 TCP 和 UDP 段结构实作二 分析 TCP 建立和释放连接4、应用层实作一 了解 DNS 解析实作二 了解 HTTP 的请求和应答 实验前准备 本部分实验用到的是抓包和协议分析软件——Wiresha

weixin_51087836的博客 8205

PHM 2010数据集解读

PHM数据挑战赛是一项面向所有潜在与会者的竞赛。今年的挑战集中在使用测力仪、加速度计和声发射数据估计高速数控铣床刀具的RUL上。 博客对PHM 2010数据集的组成和信号进行了可视化。

cnjs1994的博客 7655

SpringBoot框架总结

SpringBoot框架总结 一、SpringBoot框架的概念 1、传统框架的弊端 例如传统的SSM框架整合了MyBatis、Spring、SpringMVC框架,但其需要繁琐且重复的配置使程序员很是痛苦 2、SpringBoot框架 SpringBoot框架在传统框架的基础上对其进一步封装,只需要一些简单的配置,省去了传统框架繁琐的配置,解放了程序员,使程序员只需要关注业务而无需将经历花费在框架的配置上,大幅提高了编程的效率 二、SpringBoot框架的创建 1、idea创建SpringBoot工程

cxmengxin的博客 4898

机器人视觉联动精度优化:从±2mm到±0.02mm,产线级手眼标定全实战

2025年我接东莞长安Type-C接口分拣项目的时候,就是栽在了手眼标定上:实验室里标定完精度±0.5mm,一到产线直接掉到±2mm,机器人10次有3次抓不住,2000多件Type-C接口直接报废,还撞坏了2套汇川SCARA机器人的吸盘,本来45天的工期拖了3个月,不仅没赚到钱,还倒贴了几万块。手眼标定从来不是简单的跑个demo、算个矩阵就完事了,它是一个系统工程:从硬件选型、安装固定、相机标定、标定流程、算法优化、环境控制、重复验证,每一个环节都会影响最终的联动精度。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 392

Springboot 系列(四)Spring Boot 日志框架

注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别。 前言 Spring 框架选择使用了 JCL 作为默认日志输出。而 Spring Boot 默认选择了 SLF4J 结合 LogBack。那我们在项目中该使用哪种日志框架呢?在对于不同的第三方 jar 使用了不同的日志框架的时候,我们该怎么处理呢...

weixin_30414245的博客 471

SAP 权限配置(复合角色)

复合角色创建步骤:业务场景:通常单一角色权限颗粒度划分比较细,当需要分配单一角色权限A、B(多个单一角色)给某账号用户Y时,可以先建立一个复合角色C,将A、B绑定到复合角色C中,再将角色C分配给账号Y即完成权限配置。 业务模拟: 1、PFCG创建复合角色: 2、在角色页面添加子角色 在角色分页内添加子角色,点击“菜单”分页中的“读菜单”即可导入子角色中的菜单: 3、将用户分配给...

willieyuan的博客 7094

Python爬虫实战:利用Playwright与异步技术高效抓取链家十万级二手房数据

在开始编写代码之前,我们首先需要为项目选择合适的技术栈。1. 传统方案:Requests + BeautifulSoup优点: 简单、轻量、学习成本低。直接发送HTTP请求获取HTML,然后解析。缺点: 对于大量由JavaScript动态渲染的内容无能为力。现代网站(包括链家)大量使用JS来加载数据和实现交互,简单的HTTP请求无法获取到完整的页面内容。此外,容易被基于IP或请求头特征的反爬机制拦截。2. 进阶方案:Selenium优点。

2201_76125261的博客 891

springboot框架_Spring Boot 日志框架实践

概述Java应用中,日志一般分为以下5个级别:ERROR 错误信息WARN 警告信息INFO 一般信息DEBUG 调试信息TRACE 跟踪信息Spring Boot使用Apache的Commons Logging作为内部的日志框架,其仅仅是一个日志接口,在实际应用中需要为该接口来指定相应的日志实现。Spring Boot默认的日志实现是Java Util Logging,是JDK自带的日志包,此外...

weixin_39615257的博客 328

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Spring Boot学习记录 03SpringBoot 整合其他框架

SpringBoot整合其他框架 SpringBoot 抛弃了传统 xml 配置文件,通过JavaBean形式进行配置。因此其他配置整合需要应用说明 整合SpringMVC SpringBoot 对 SpringMVC 的一些自动配置可以满足大部分需求,但也可以自定义配置类 并实现WebMvcConfigurer接口 进行配置 WebMvcConfigurer接口主要重写的方法 返回 方法 说明 void addInterceptors(InterceptorRegistry registr

柏竹的博客 691

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

springBoot框架理解

1.起源 Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。用我的话来理解,就是 Spring Boot 其实不是什么新的框架,它默认配置了很多框架的使用方式,就像 Maven 整合了所有的 Jar 包,Spring Boot 整合了所有的框...

3万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

SpringBoot框架介绍

什么是SpringBoot 什么是SpringBoot呢,就是一个javaweb的开发框架,和SpringMVC类似,对比其他javaweb框架的好处,官方说是简化开发,约定大于配置, you can “just run”,能迅速的开发web应用,几行代码开发一个http接口。 所有的技术框架的发展似乎都遵循了一条主线规律:从一个复杂应用场景 衍生 一种规范框架,人们只需要进行各种配置而不需要自己去实现它,这时候强大的配置功能成了优点;发展到一定程度之后,人们根据实际生产应用情况,选取其中实用功能和设计精

weixin_45608165的博客 8895

spring boot 日志乱码_SpringBoot整合日志框架

>SpringBoot版本:2.1.1.RELEASE当我们在进行web开发时,经常会用到各种各样的框架,常见的有spring、mybatis、hibernate等等,每个框架底层都有着自己的日志实现,那么难道我们在进行开发时,还需要在使用不同框架的时候使用其对应的API嘛?这将会大大增加我们的开发成本。还有如果我们在后期对项目进行二次开发时,如果要换日志框架,难道还得需要把原本的日志AP...

weixin_39616961的博客 661

spring boot框架_Spring和SpringBoot比较,解惑区别

1、概述:对于Spring和SpringBoot到底有什么区别,我听到了很多答案,刚开始迈入学习SpringBoot的我当时也是一头雾水,随着经验的积累、我慢慢理解了这两个框架到底有什么区别,我相信对于用了SpringBoot很久的开发人员来说,有绝大部分还不是很理解SpringBoot到底和Spring有什么区别,看完文章中的比较,或许你有了不同的答案和看法!2、什么是Spring呢?先来聊一聊...

weixin_39730284的博客 559

spring boot框架_Java人员如何快速构建属于自己的SpringBoot框架?

SpringBoot框架已经成为Java开发人员必须掌握的框架之一,它的简洁、高效、易扩展性是它成为当今JavaWeb开发领域最受欢迎的框架,它并不是一款全新的框架,它以Spring框架为基础,整合其他第三方框架,为开发者提供了更加轻松、愉快的开发模式,下面我们一步步来搭建一套属于我们自己的SpringBoot框架。第一步、配置依赖这里我们使用Maven来构建项目,下面我先将完整的pom.xml贴...

weixin_39570505的博客 399
上一篇: 初识Python(入门)
下一篇: 遇见狂神说Apach POI,EasyExcel笔记
星悦糖
博客等级 码龄5年 6万+粉丝 50原创
评论 48
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星悦糖

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址