随笔分类 - >>>>>>已整理的分类 / SpringBoot
摘要:
从开始使用SpringBoot到现在,一直都是在用SpringBoot开发web服务(API服务),其实SpringBoot也支持非web项目。 Spring诞生之初就不是为web项目定制的,SpringBoot无非是在spring核心项目的基础上添加了一些方便开发者使用的组件,所以使用Spring
阅读全文

摘要:
一般项目执行后,当程序结束会自动关闭程序。但Springboot项目,启动后,只要不发生error错误,一般不会自动停止。 这是为什么呢? 简单Java阻止停止 为了保证一个服务能够持续有效地对外提供服务,一般会有相应的处理方式,比如: 服务器上的守护进程脚本 但是,在Java代码层面,除了shel
阅读全文

摘要:
Redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集
阅读全文

摘要:
启动:./app.sh start 停止:./app.sh stop 重启:./app.sh restart 输出运行状态:./app.sh status app.sh 文件放至 jar 同目录。 app.sh内容: #!/bin/sh ## java 此处是指定jdk启动 export JAVA_
阅读全文

摘要:
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-ins
阅读全文

摘要:
背景 最近有个需求,就是需要从resources目录下读取文件返回给用户。在idea中运行时,有些resources下文件读取工具类能够正常获取读取到文件。但是通过java –jar的方式去运行jar包,此时resources下文件读取工具类读取文件就失效了。通过查询搜索,了解到了是读取的方式导致文
阅读全文

摘要:
SpringBoot内置Tomcat,在默认设置中,Tomcat的最大线程数是200,最大连接数是10000。默认情况下,支持最大并发量为一万,也就是指支持的连接数。 Tomcat有两种处理连接的模式 是BIO,一个线程只处理一个Socket连接 是NIO,一个线程处理多个Socket连接 处理多个
阅读全文

摘要:
项目结构: pom.xml: <!--① 指定打包成war--> <packaging>war</packaging> <dependencies> <!-- starter-web:spring-webmvc + autoconfigure + logback + yaml + tomcat --
阅读全文

摘要:
SpringBoot 实现定时任务很简单,只需要使用@Scheduled注解即可,但是该注解是实现的定时任务默认是单线程的,也就意味着多个定时任务执行时就可能导致线程堵塞,延缓定时任务的执行。所以在需要的时候,我们可以设置一个线程池去执行定时任务。 在启动类上加入@EnableScheduling注
阅读全文

摘要:
yml或者properties文件没有被扫描到,需要在pom文件中<build></build>添加如下内容来保证文件都能正常被扫描到并且加载成功。 <resources> <resource> <directory>src/main/java</directory> <includes> <inc
阅读全文

摘要:
添加test依赖: <!-- starter-test:junit + spring-test + mockito --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter
阅读全文

摘要:
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '@' that cannot start any token. (Do not use
阅读全文

摘要:
本文介绍了脚手架常用三种方式。以及通过maven archtype搭建一个脚手架和基于脚手架构建项目的流程。 脚手架介绍 为什么要有脚手架 脚手架好处有: 统一研发框架 提升研发效率,减少搭建项目的时间。 脚手架三种方式 1、搭建一个服务demo 每次需要创建一个新服务项目时,就拉取下这个服务的代码
阅读全文

摘要:
aop切面的方式 实现思路 引入aop依赖 自定义注解 定义切面,采用环绕通知 代码实现 引入依赖 <!--aop--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-
阅读全文

摘要:
多线程方式一:实现AsyncConfigurer 接口 配置类实现接口AsyncConfigurer,返回一个ThreadPoolTaskExecutor 线程池对象。 @Configuration @EnableAsync public class AsyncConfig implements A
阅读全文

摘要:
Spring Boot Admin,这是一个开源社区项目,用于管理和监控SpringBoot应用程序。这个项目中包含有客户端和服务端两部分,而监控平台指的就是服务端。我们做的程序如果需要被监控,将我们做的程序制作成客户端,然后配置服务端地址后,服务端就可以通过HTTP请求的方式从客户端获取对应的信息
阅读全文

摘要:
Idea 2019版本 择Edit Configurations进入选项编辑 分别启动RocketMQApp和RocketMQApp2,不过端口不能一样,可以启动前进行修改再启动。 或者设置随机端口: server: port: ${random.int[10000,19999]} #${rando
阅读全文

摘要:
idea项目中有多个Springboot项目,项目启动的时候会一个个找启动类很不方便,现在我们配置下idea中的Run DashBoard功能就可以解决我们遇到的问题。 1、找到项目的.idea目录,然后找到workspace.xml文件,打开文件找到如下内容 <component name="Ru
阅读全文

摘要:
actuator简介 Spring Boot Actuator就是一款可以帮助你监控系统数据的框架,其可以监控很多很多的系统数据,它有对应用系统的自省和监控的集成功能,可以查看应用配置的详细信息,如: 显示应用程序员的Health健康信息 显示Info应用信息 显示HTTP Request跟踪信息
阅读全文

摘要:
1、创建SpringBoot项目 2、添加相关的依赖 <packaging>war</packaging> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-
阅读全文
