公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

详解SpringBoot获得Maven-pom中版本号和编译时间戳 主要介绍了详解SpringBoot获得Maven-pom中版本号和编译时间戳,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 立即下载

前言

我们刚开始学习 JavaWeb 的时候,使用 Servlet/JSP 做开发,一个接口搞一个 Servlet ,很头大,后来我们通过隐藏域或者反射等方式,可以减少 Servlet 的创建,但是依然不方便,再后来,我们引入Struts2/SpringMVC 这一类的框架,来简化我们的开发 ,和 Servlet/JSP 相比,引入框架之后,生产力确实提高了不少,但是用久了,又发现了新的问题,即配置繁琐易出错,要做一个新项目,先搭建环境,环境搭建来搭建去,就是那几行配置,不同的项目,可能就是包不同,其他大部分的配置都是一样的,Java 总是被人诟病配置繁琐代码量巨大,这就是其中一个表现。那么怎么办?Spring Boot 应运而生,Spring Boot 主要提供了如下功能:

  1. 为所有基于 Spring 的 Java 开发提供方便快捷的入门体验。
  2. 开箱即用,有自己自定义的配置就是用自己的,没有就使用官方提供的默认的。
  3. 提供了一系列通用的非功能性的功能,例如嵌入式服务器、安全管理、健康检测等。
  4. 绝对没有代码生成,也不需要XML配置。

Spring Boot 的出现让 Java 开发又回归简单,因为确确实实解决了开发中的痛点,因此这个技术得到了非常广泛的使用,我很多朋友出去面试 Java 工程师,从2017年年初开始,Spring Boot基本就是必问,现在流行的 Spring Cloud 微服务也是基于 Spring Boot,因此,所有的 Java 工程师都有必要掌握好 Spring Boot。

内容简介:

1.纯Java搭建SSM项目

在 Spring Boot 项目中,正常来说是不存在 XML 配置,这是因为 Spring Boot 不推荐使用 XML ,注意,并非不支持,Spring Boot 推荐开发者使用 Java 配置来搭建框架,Spring Boot 中,大量的自动化配置都是通过 Java 配置来实现的,这一套实现方案,我们也可以自己做,即自己也可以使用纯 Java 来搭建一个 SSM 环境,即在项目中,不存在任何 XML 配置,包括 web.xml 。

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

2.创建一个spring boot项目的三种方式

初学者看到 Spring Boot 工程创建成功后有那么多文件就会有点懵圈,其实 Spring Boot 工程本质上就是一个 Maven 工程,从这个角度出发,松哥在这里向大家介绍三种项目创建方式。

  • 在线创建
  • 使用开发工具创建
  • Maven 创建

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

3.理解 Spring Boot 项目中的 parent

基本功能

当我们创建一个 Spring Boot 工程时,可以继承自一个 spring-boot-starter-parent ,也可以不继承自它,我们先来看第一种情况。先来看 parent 的基本功能有哪些?

  1. 定义了 Java 编译版本为 1.8 。
  2. 使用 UTF-8 格式编码。
  3. 继承自 spring-boot-dependencies ,这个里边定义了依赖的版本,也正是因为继承了这个依赖,所以我们在写依赖时才不需要写版本号。
  4. 执行打包操作的配置。
  5. 自动化的资源过滤。
  6. 自动化的插件配置。
  7. 针对 application.properties 和 application.yml 的资源过滤,包括通过 profifile 定义的不同环境的配置文件,例如 application-dev.properties 和 application-dev.yml。

请注意,由于application.properties和application.yml文件接受Spring样式占位符 $ {...} ,因此 Maven 过滤更改为使用 @ .. @ 占位符,当然开发者可以通过设置名为 resource.delimiter 的Maven 属性来覆盖 @ .. @ 占位符。

源码分析

当我们创建一个 Spring Boot 项目后,我们可以在本地 Maven 仓库中看到看到这个具体的 parent 文件,以 2.1.8 这个版本为例,松哥 这里的路径是C:\Users\sang\.m2\repository\org\springframework\boot\spring-boot-starterparent\2.1.8.RELEASE\spring-boot-starter-parent-2.1.8.RELEASE.pom ,打开这个文件,快速阅读文件源码,基本上就可以证实我们前面说的功能,如下图

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

4.理解Spring Boot 配置文件 application.properties

位置问题

首先,当我们创建一个 Spring Boot 工程时,默认 resources 目录下就有一个 application.properties文件,可以在 application.properties 文件中进行项目配置,但是这个文件并非唯一的配置文件,在Spring Boot 中,一共有 4 个地方可以存放 application.properties 文件。

  1. 当前项目根目录下的 confifig 目录下
  2. 当前项目的根目录下
  3. resources 目录下的 confifig 目录下
  4. resources 目录下

按如上顺序,四个配置文件的优先级依次降低。如下:

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

5.Spring Boot中的 yaml 配置

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

6.自定义 Spring Boot 中的 starter

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

7.理解自动化配置的原理

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

8.Spring Boot 中配置 Https

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

9.Spring Boot 整合 Thymeleaf

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

10.Spring Boot 整合 Freemarker

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

11.Spring Boot 中的静态资源配置

12.@ControllerAdvice 的三种使用场景

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

13.Spring Boot 中的全局异常处理

14.CORS 解决跨域问题

15.定义系统启动任务的两种方式

16.定时任务的两种实现方式

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

总结:

可以毫不夸张地说,这篇文章介绍的 SpringBoot 教程基本已经涵盖你工作中遇到的大部分常用的场景。对于每一个springboot的用法,文中都会都会有详细的教程解释。

本文总共从29个章节,248页PDF,阐述springboot在各种环境下的各种用法,文中给大家列举出部分的springboot教程,需要这份10万字节springboot全教程PDF的朋友,可以关注小编+转发文章+私信【666】获取。

公司刚来的阿里p8,看完我构建的springboot框架,甩给我一份文档

 

SU-03T1语音模组固件烧录与配置全指南 本文提供SU-03T1离线语音模组固件烧录与配置的完整指南。详细介绍了从硬件连接、软件环境搭建,到在智能公元平台定制唤醒词、命令词及引脚配置,最后使用专用工具完成固件烧录的全流程。重点解析了烧录过程中的关键步骤与常见问题解决方法,帮助开发者快速实现智能语音控制功能。 阅读详情

相关推荐

YOLOv8中的C2f模块代码详解

在YOLOv8网络结构中,C2f模块(CSP Bottleneck with 2 Convolutions)是一个关键组件,用于实现跨阶段部分聚合

zzzyyy8的博客 3万+

springboot 获取项目版本

springboot 获取项目/模块版本号 1. pom.xml文件标签中添加 <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes&gt...

qq_44399112的博客 1952

【PB03F 超详细-环境搭建】蓝牙5.2安信可PB-03F-Kit开发板二次开发环境搭建

PB-03是由深圳市安信可科技有限公司开发的蓝牙模块。本博文介绍安信可PB-03F-Kit开发板的基本情况、开发环境搭建,以及以点亮LED为例介绍程序编写和固件烧录的操作流程。 安信可PB-03F-Kit开发板使用的PHY6252这样一款高集成度的低功耗蓝牙系统级芯片(SoC),专为物联网(IoT)、移动设备、可穿戴电子设备、智能家居等各种应用而设计。......

qq_44078824的博客 1万+

Spring Boot 补充版本

认证表单认证OAuth2.0认证SAML2.0认证CAS认证RememberMe认证JAAS认证OpenId去中心化认证X509认证Http Basic认证认证授权url请求授权方法访授权SpEl访问控制ACLRBAC配置文件中默认的前缀:当我们在配置文件中配置自己的用户名密码,默认密码(uuid生成的)就不在打印了获取用户权限获取用户的登陆凭证!getDetails获取用户携带的一些详细信息,一般来说就是当前请求的对象。获取当前用户对象当前用户是否认证成功。

光头小小强007的博客 1085

高速窄脉冲峰值保持设计

一、目的 在激光探测领域,探测器发出的高速窄脉冲,单片机AD进行采样,很难捕捉到窄脉冲的幅值,即使使用高速AD进行采样,也存在一定的难度。因此,本方案设计了一种高速窄脉冲峰值保持电路,有助于单片机AD采样能很好的捕捉到脉冲幅值。 二、方案分析与比较 峰值保持器一般分为两种:电压型和跨导型。 方案一:电压型峰值保持器,由电压型运放、二极管、保持电容、缓冲器组成,优点是元件成本低,缺点是峰值保持存在过...

weixin_43184208的博客 9312

C#与发那科机器人通信实战:从SDK配置到机械臂控制

本文详细介绍了如何使用C#与发那科机器人进行通信,从SDK配置到机械臂控制的完整实战流程。内容包括环境准备、通信连接建立、机械臂运动控制、异常处理与状态监控,以及高级功能实战,帮助开发者快速掌握工业机器人编程技术。

weixin_42524276的博客 462

springboot自定义版本号

1.自定义版本号注解 @Target({ElementType.METHOD, ElementType.TYPE}) // 类上和方法上都可以 @Retention(RetentionPolicy.RUNTIME) @Documented @Mapping //spring的元注释,表示 Web 映射注释 public @interface ApiVersion { /** * 自定义版本号 */ int value() default 1; } 2.自定义版本号筛选规则 实现RequestC

zcl_1991的博客 1263

【FPGA教程案例100】深度学习1——基于CNN卷积神经网络的手写数字识别纯Verilog实现,使用mnist手写数字数据库

MNIST 数据库有一个 60,000 示例的训练集,还有一个 10,000 示例的测试集。这些数字已在大小方面规范化,在固定大小的图像中居中。如下图所示:我们任意选择0~9是个数字,将其转化为数字:0_0.txt1_0.txt2_0.txt3_0.txt4_0.txt5_0.txt6_0.txt7_0.txt8_0.txt9_0.txt。

FPGA/MATLAB学习教程/源码/项目合作开发 7846

spring 添加版本号/md5

经过同事帮助,不断测试,发现如下问题 添加版本号 阅览文章 Spring-Boot整合freemarker引入静态资源css、js等 http://www.toutiao.com/a6428064889595871490/ 一、概述 1.springboot 默认静态资源访问的路径为: /static 或 /public 或 /resources 或 /META-INF/resources 这样的地址都必须定义在src/main/resources目录文件中,达到在项目启动时 自动加载 项目静态地址目

m0_56463670的博客 919

大厂面试:字节跳动大数据面试题及参考答案(10万字长文及多张原理图持续更新)

在 Spark 中,宽窄依赖是用来描述 RDD(弹性分布式数据集)之间的依赖关系的概念。窄依赖是指父 RDD 的每个分区最多被一个子 RDD 的分区使用,即子 RDD 的分区可以通过确定的规则从父 RDD 的分区计算得到,并且不需要跨节点进行数据传输。窄依赖通常可以在一个节点上进行计算,不需要进行数据的 shuffle 操作,因此性能较高。宽依赖是指父 RDD 的一个分区可能被多个子 RDD 的分区使用,即子 RDD 的分区需要通过跨节点的数据 shuffle 操作从父 RDD 的多个分区获取数据。

大模型大数据攻城狮的专栏 1654

群无人机航迹规划-虚拟管道

图源北理工全权老师团队虚拟管道相关论文,文字为个人理解,以ppt形式分享报告。

coldmood77的博客 670

1.14 springboot-01

springboo-011.认识springboot1. springboot是什么?2. springboot是做什么的?3. springboot的优缺点优点:缺点:4.当前场景4.1 微服务4.2 分布式技术分布式的困难分布式的解决4.3 云原生上云的困难上云的解决5. springboot的详细认识2. springboot基础1.工具版本1.1 maven配置2. 创建项目2.1 创建maven工程(略)2.2 引入springboot所需依赖2.3 创建主程序2.4 编写测试代码2.5 通过网页

jiaguopeng的博客 346

EMD (经验模态分解) 在 C++ 中的实现指南

EMD 是由 Norden E. Huang 等人在1998年提出的一种适用于非线性和非平稳信号的分析方法。对称性:IMF 的上下包络对称。零交叉点:IMF 的零交叉点数量与极值点数量相同或相差一个。本文详细介绍了如何在C++中实现EMD,包括理论背景、算法步骤、代码实现和优化等内容。通过丰富的代码示例和详细的解释,希望能够帮助读者掌握EMD的基本原理,并能够在实际项目中灵活应用。未来,随着信号处理技术的不断发展,EMD及其变种(如EEMD、CEEMDAN等)将继续在各个领域发挥重要作用。

qq_38334677的博客 1754

公司刚来的阿里 p8,看完我构建的 springboot 框架,甩给我一份文档

给大家送一个小福利附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!职业规划迷茫的朋友们。[外链图片转存中…(img-iYjTNWnw-1712763705005)]《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

2401_84047990的博客 981

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: Alibaba面试官提问:说说你对消息队列的理解
下一篇: 阿里资深架构师分享之全程手写Spring
java架构师小芷
博客等级 码龄6年 216粉丝 519原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址