当前位置: 首页 > news >正文

SpringBoot2知识点记录

SpringBoot2知识点记录

  • 1.SpringBoot2基础入门
    • 1.1 环境要求
      • 1.1.1 maven设置
    • 1.2 第一个程序 HelloWorld
      • 1.2.1 创建maven工程
      • 1.2.2 引入依赖
      • 1.2.3 创建主程序
      • 1.2.4 编写业务
      • 1.2.5 测试
      • 1.2.6 简化配置
      • 1.2.7 简化部署
    • 1.3 自动装配
      • 1.3.1 SpringBoot特点
        • 1.3.1.1 依赖管理
        • 1.3.1.2 自动装配
      • 1.3.2 容器功能
        • 1.3.2.1 底层注解
          • (1)@Configuration
        • 1.3.2.2
        • 1.3.2.3
        • 1.3.2.4
      • 1.3.3 自动装配原理入门
      • 1.3.4 开发小技巧
  • 2.SpringBoot2核心功能
  • 3.


1.SpringBoot2基础入门

1.1 环境要求

  • Java 8 (JDK1.8)
  • Maven 3.3+
  • idea

1.1.1 maven设置

配置maven的阿里云下载路径和java的jdk版本为1.8

  <mirrors><mirror><id>nexus-aliyun</id><mirrorOf>central</mirrorOf><name>Nexus aliyun</name><url>http://maven.aliyun.com/nexus/content/groups/public</url></mirror></mirrors><profile><id>jdk-1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties></profile></profiles>

1.2 第一个程序 HelloWorld

1.2.1 创建maven工程

创建maven工程

1.2.2 引入依赖

pom.xml中导入依赖包

    <!--导入SpringBoot 2.3.4版本--><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.4.RELEASE</version></parent><dependencies><!--开发web场景模式的包--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>

1.2.3 创建主程序

package com.atguigu.boot;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** 主程序类* @SpringBootApplication:标识这是一个SpringBoot程序应用*/
@SpringBootApplication
public class MainApplication {public static void main(String[] args) {SpringApplication.run(MainApplication.class,args);}
}

1.2.4 编写业务

package com.atguigu.boot.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class HelloController {@RequestMapping("/hello")public String handle01(){return "hello,SpringBoot2";}
}

1.2.5 测试

在这里插入图片描述

1.2.6 简化配置

SpringBoot简化了配置文件,所有的配置文件可以全部存放在application.properties文件中。
文件存放路径:src/main/resources/application.properties

#设置端口号
server.port=8080

1.2.7 简化部署

把项目打成jar包,直接在目标服务器执行即可。

    <!--引入依赖,项目打包成jar包--><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

直接打包成jar包,可以在目标服务器上面执行打开。
注意:需要关闭cmd属性中的快捷编辑,否则会卡住项目执行。

在这里插入图片描述

1.3 自动装配

1.3.1 SpringBoot特点

1.3.1.1 依赖管理

父项目做资源来管理,存放了很多依赖的版本号,可以在pom.xml中引入的时候,不需要写过多的版本号。

在这里插入图片描述

1.3.1.2 自动装配

自动装配了很多常见的开发场景,不需要像SpringMVC一样整合起来需要配置很多东西。

1.3.2 容器功能

1.3.2.1 底层注解

(1)@Configuration

@Bean、@Component、@Controller、@Service、@Repository
@ComponentScan、@Import
@Conditional

1.3.2.2

1.3.2.3

1.3.2.4

1.3.3 自动装配原理入门

1.3.4 开发小技巧

2.SpringBoot2核心功能

3.

http://www.lryc.cn/news/5738.html

相关文章:

  • Mysql
  • Q4营收利润增长背后估值持续偏低,全球支付巨头PayPal前景如何?
  • 【自然语言处理】【大模型】BLOOM:一个176B参数且可开放获取的多语言模型
  • 小红书穿搭博主推广费用是多少?
  • 网络安全-PHPstudy环境搭建
  • operator的两种用法(重载和隐式类型转换)
  • vue常用指令
  • MATLAB | 有关数值矩阵、颜色图及颜色列表的技巧整理
  • C++模板元编程详细教程(之九)
  • PhysioNet2017分类的代码实现
  • 正大期货本周财经大事抢先看
  • html+css综合练习一
  • 安装jdk8
  • 二分法心得
  • Linux安装Docker完整教程
  • 备份基础知识
  • C++学习记录——팔 内存管理
  • Spring事务失效原因分析解决
  • 4个月的测试经验,来面试就开口要17K,面试完,我连5K都不想给他.....
  • python学习之pyecharts库的使用总结
  • 【taichi】利用 taichi 编写深度学习算子 —— 以提取右上三角阵为例
  • 二进制 k8s 集群下线 worker 组件流程分析和实践
  • Bean的六种作用域
  • Http发展历史
  • 高级Java程序员必备的技术点,你会了吗?
  • 【暴力量化】查找最优均线
  • Java读取mysql导入的文件时中文字段出现�??的乱码如何解决
  • k8s核心概念—Pod Controller Service介绍——20230213
  • Tensorflow的数学基础
  • IT培训就是“包就业”吗?内行人这么看