SpringBoot 速记
nanshan 2024-11-24 19:36 19 浏览 0 评论
Demo 脚手架项目地址:
https://github.com/Vip-Augus/springboot-note
Table of Contents generated with DocToc
- SpringBoot 速记构建项目SpringBoot 基础配置Spring Boot Starters@SpringBootApplicationWeb 容器配置常规配置HTTPS 配置@ConfigurationPropertiesProfile@ControllerAdvice 用来处理全局数据@ExceptionHandler 错误处理@ModelAttribute 视图属性CORS 支持,跨域资源共享注册 MVC 拦截器开启 AOP 切面控制整合 Mybatis 和 Druid一、添加 mybatis 和 druid 依赖二、配置数据库和连接池参数三、其他 mybatis 配置整合 Redis一、引用 Redis 依赖二、参数配置三、代码使用发送 HTML 样式的邮件一、引入依赖二、配置邮箱的参数三、写模板和发送内容整合 Swagger (API 文档)一、引入依赖二、配置 Swagger 参数总结参考资料
构建项目
相比于使用 IDEA 的模板创建项目,我更推荐的是在 Spring 官网上选择参数一步生成项目
https://start.spring.io/
我们只需要做的事情,就是修改组织名和项目名,点击 Generate the project,下载到本地,然后使用 IDEA 打开
这个时候,不需要任何配置,点击 Application 类的 run 方法就能直接启动项目。
SpringBoot 基础配置
Spring Boot Starters
引用自参考资料 1 描述:
starter的理念:starter 会把所有用到的依赖都给包含进来,避免了开发者自己去引入依赖所带来的麻烦。需要注意的是不同的 starter 是为了解决不同的依赖,所以它们内部的实现可能会有很大的差异,例如 jpa 的 starter 和 Redis 的 starter 可能实现就不一样,这是因为 starter 的本质在于 synthesize,这是一层在逻辑层面的抽象,也许这种理念有点类似于 Docker,因为它们都是在做一个“包装”的操作,如果你知道 Docker 是为了解决什么问题的,也许你可以用 Docker 和 starter 做一个类比。
我们知道在 SpringBoot 中很重要的一个概念就是,「约定优于配置」,通过特定方式的配置,可以减少很多步骤来实现想要的功能。
例如如果我们想要使用缓存 Redis
在之前的可能需要通过以下几个步骤:
- 在 pom 文件引入特定版本的 redis
- 在 .properties 文件中配置参数
- 根据参数,新建一个又一个 jedis 连接
- 定义一个工具类,手动创建连接池来管理
经历了上面的步骤,我们才能正式使用 Redis
但在 Spring Boot 中,一切因为 Starter 变得简单
- 在 pom 文件中引入 spring-boot-starter-data-redis
- 在 .properties 文件中配置参数
通过上面两个步骤,配置自动生效,具体生效的 bean 是 RedisAutoConfiguration,自动配置类的名字都有一个特点,叫做 xxxAutoConfiguration。
可以来简单看下这个类:
@Configuration
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
@Import({ LettuceConnectionConfiguration.class, JedisConnectionConfiguration.class })
public class RedisAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "redisTemplate")
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)
throws UnknownHostException {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
return template;
}
@Bean
@ConditionalOnMissingBean
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory)
throws UnknownHostException {
StringRedisTemplate template = new StringRedisTemplate();
template.setConnectionFactory(redisConnectionFactory);
return template;
}
}
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {...}
可以看到,Redis 自动配置类,读取了以 spring.redis 为前缀的配置,然后加载 redisTemplate 到容器中,然后我们在应用中就能使用 RedisTemplate 来对缓存进行操作~(还有很多细节没有细说,例如 @ConditionalOnMissingBean 先留个坑(●′?`●)?)
@Autowired
private RedisTemplate redisTemplate;
ValueOperations ops2 = redisTemplate.opsForValue();
Book book = (Book) ops2.get("b1");
@SpringBootApplication
该注解是加载项目的启动类上的,而且它是一个组合注解:
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {...}
下面是这三个核心注解的解释:
注解名解释@SpringBootConfiguration表明这是一个配置类,开发者可以在这个类中配置 Bean@EnableAutoConfiguration表示开启自动化配置@ComponentScan完成包扫描,默认扫描的类位于当前类所在包的下面
通过该注解,我们执行 mian 方法:
SpringApplication.run(SpringBootLearnApplication.class, args);
就可以启动一个 SpringApplicaiton 应用了。
Web 容器配置
常规配置
配置名解释server.port=8081配置了容器的端口号,默认是 8080server.error.path=/error配置了项目出错时跳转的页面server.servlet.session.timeout=30msession 失效时间,m 表示分钟,如果不写单位,默认是秒 sserver.servlet.context-path=/项目名称,不配置时默认为/。配置后,访问时需加上前缀server.tomcat.uri-encoding=utf-8Tomcat 请求编码格式server.tomcat.max-threads=500Tomcat 最大线程数server.tomcat.basedir=/home/tmpTomcat 运行日志和临时文件的目录,如不配置,默认使用系统的临时目录
HTTPS 配置
配置名解释server.ssl.key-store=xxx秘钥文件名server.ssl.key-alias=xxx秘钥别名server.ssl.key-store-password=123456秘钥密码
想要详细了解如何配置 HTTPS,可以参考这篇文章 Spring Boot 使用SSL-HTTPS
@ConfigurationProperties
这个注解可以放在类上或者 @Bean 注解所在方法上,这样 SpringBoot 就能够从配置文件中,读取特定前缀的配置,将属性值注入到对应的属性。
使用例子:
@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
public class DruidConfigBean {
private Integer initialSize;
private Integer minIdle;
private Integer maxActive;
private List<String> customs;
...
}
application.properties
spring.datasource.initialSize=5
spring.datasource.minIdle=5
spring.datasource.maxActive=20
spring.datasource.customs=test1,test2,test3
其中,如果对象是列表结构,可以在配置文件中使用 , 逗号进行分割,然后注入到相应的属性中。
Profile
使用该属性,可以快速切换配置文件,在 SpringBoot 默认约定中,不同环境下配置文件名称规则为 application-{profile}.propertie,profile 占位符表示当前环境的名称。
1、配置 application.properties
spring.profiles.active=dev
2、在代码中配置 在启动类的 main 方法上添加 setAdditionalProfiles("{profile}");
SpringApplicationBuilder builder = new SpringApplicationBuilder(SpringBootLearnApplication.class);
builder.application().setAdditionalProfiles("prod");
builder.run(args);
3、启动参数配置
java -jar demo.jar --spring.active.profile=dev
@ControllerAdvice 用来处理全局数据
@ControllerAdvice 是 @Controller 的增强版。主要用来处理全局数据,一般搭配 @ExceptionHandler 、@ModelAttribute 以及 @InitBinder 使用。
@ExceptionHandler 错误处理
/**
* 加强版控制器,拦截自定义的异常处理
*
*/
@ControllerAdvice
public class CustomExceptionHandler {
// 指定全局拦截的异常类型,统一处理
@ExceptionHandler(MaxUploadSizeExceededException.class)
public void uploadException(MaxUploadSizeExceededException e, HttpServletResponse response) throws IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.write("上传文件大小超出限制");
out.flush();
out.close();
}
}
@ModelAttribute 视图属性
@ControllerAdvice
public class CustomModelAttribute {
//
@ModelAttribute(value = "info")
public Map<String, String> userInfo() throws IOException {
Map<String, String> map = new HashMap<>();
map.put("test", "testInfo");
return map;
}
}
@GetMapping("/hello")
public String hello(Model model) {
Map<String, Object> map = model.asMap();
Map<String, String> infoMap = (Map<String, String>) map.get("info");
return infoMap.get("test");
}
- key : @ModelAttribute 注解中的 value 属性
- 使用场景:任何请求 controller 类,通过方法参数中的 Model 都可以获取 value 对应的属性
CORS 支持,跨域资源共享
CORS(Cross-Origin Resource Sharing),跨域资源共享技术,目的是为了解决前端的跨域请求。
引用:当一个资源从与该资源本身所在服务器不同的域或端口请求一个资源时,资源会发起一个跨域HTTP请求
详细可以参考这篇文章-springboot系列文章之实现跨域请求(CORS),这里只是记录一下如何使用:
例如在我的前后端分离 demo 中,如果没有通过 Nginx 转发,那么将会提示如下信息:
Access to fetch at ‘http://localhost:8888/login’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: The value of the ‘Access-Control-Allow-Credentials’ header in the response is ‘’ which must be ‘true’ when the request’s credentials mode is ‘include’
为了解决这个问题,在前端不修改的情况下,需要后端加上如下两行代码:
// 第一行,支持的域
@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/login", method = RequestMethod.GET)
@ResponseBody
public String login(HttpServletResponse response) {
// 第二行,响应体添加头信息(这一行是解决上面的提示)
response.setHeader("Access-Control-Allow-Credentials", "true");
return HttpRequestUtils.login();
}
注册 MVC 拦截器
在 MVC 模块中,也提供了类似 AOP 切面管理的扩展,能够拥有更加精细的拦截处理能力。
核心在于该接口:HandlerInterceptor,使用方式如下:
/**
* 自定义 MVC 拦截器
*/
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 在 controller 方法之前调用
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// 在 controller 方法之后调用
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
// 在 postHandle 方法之后调用
}
}
注册代码:
/**
* 全局控制的 mvc 配置
*/
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new MyInterceptor())
// 表示拦截的 URL
.addPathPatterns("/**")
// 表示需要排除的路径
.excludePathPatterns("/hello");
}
}
拦截器执行顺序: preHandle -> controller -> postHandle -> afterCompletion,同时需要注意的是,只有 preHandle 方法返回 true,后面的方法才会继续执行。
开启 AOP 切面控制
切面注入是老生常谈的技术,之前学习 Spring 时也有了解,可以参考我之前写过的文章参考一下:
Spring自定义注解实现AOP
Spring 源码学习(八) AOP 使用和实现原理
在 SpringBoot 中,使用起来更加简便,只需要加入该依赖,使用方法与上面一样。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
整合 Mybatis 和 Druid
SpringBoot 整合数据库操作,目前主流使用的是 Druid 连接池和 Mybatis 持久层,同样的,starter 提供了简洁的整合方案
项目结构如下:
一、添加 mybatis 和 druid 依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.18</version>
</dependency>
二、配置数据库和连接池参数
# 数据库配置
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=12345678
# druid 配置
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=20
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-wait=60000
spring.datasource.druid.pool-prepared-statements=true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20
spring.datasource.druid.max-open-prepared-statements=20
spring.datasource.druid.validation-query=SELECT 1
spring.datasource.druid.validation-query-timeout=30000
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=false
#spring.datasource.druid.time-between-eviction-runs-millis=
#spring.datasource.druid.min-evictable-idle-time-millis=
#spring.datasource.druid.max-evictable-idle-time-millis=10000
# Druid stat filter config
spring.datasource.druid.filters=stat,wall
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
# session 监控
spring.datasource.druid.web-stat-filter.session-stat-enable=true
spring.datasource.druid.web-stat-filter.session-stat-max-count=10
spring.datasource.druid.web-stat-filter.principal-session-name=admin
spring.datasource.druid.web-stat-filter.principal-cookie-name=admin
spring.datasource.druid.web-stat-filter.profile-enable=true
# stat 监控
spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*
spring.datasource.druid.filter.stat.db-type=mysql
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.filter.stat.slow-sql-millis=1000
spring.datasource.druid.filter.stat.merge-sql=true
spring.datasource.druid.filter.wall.enabled=true
spring.datasource.druid.filter.wall.db-type=mysql
spring.datasource.druid.filter.wall.config.delete-allow=true
spring.datasource.druid.filter.wall.config.drop-table-allow=false
# Druid manage page config
spring.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
spring.datasource.druid.stat-view-servlet.reset-enable=true
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=admin
#spring.datasource.druid.stat-view-servlet.allow=
#spring.datasource.druid.stat-view-servlet.deny=
spring.datasource.druid.aop-patterns=cn.sevenyuan.demo.*
三、其他 mybatis 配置
本地工程,将 xml 文件放入 resources 资源文件夹下,所以需要加入以下配置,让应用进行识别:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
...
</build>
通过上面的配置,我本地开启了三个页面的监控:SQL 、 URL 和 Sprint 监控,如下图:
通过上面的配置,SpringBoot 很方便的就整合了 Druid 和 mybatis,同时根据在 properties 文件中配置的参数,开启了 Druid 的监控。
但我根据上面的配置,始终开启不了 session 监控,所以如果需要配置 session 监控或者调整参数具体配置,可以查看官方网站
alibaba/druid
整合 Redis
我用过 Redis 和 NoSQL,但最熟悉和常用的,还是 Redis ,所以这里记录一下如何整合
一、引用 Redis 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<artifactId>lettuce-core</artifactId>
<groupId>io.lettuce</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
二、参数配置
# redis 配置
spring.redis.database=0
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=
spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.max-wait=-1ms
spring.redis.jedis.pool.min-idle=0
三、代码使用
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@GetMapping("/testRedis")
public Book getForRedis() {
ValueOperations<String, String> ops1 = stringRedisTemplate.opsForValue();
ops1.set("name", "Go 语言实战");
String name = ops1.get("name");
System.out.println(name);
ValueOperations ops2 = redisTemplate.opsForValue();
Book book = (Book) ops2.get("b1");
if (book == null) {
book = new Book("Go 语言实战", 2, "none name", BigDecimal.ONE);
ops2.set("b1", book);
}
return book;
}
这里只是简单记录引用和使用方式,更多功能可以看这里:Spring Data Redis(一)–解析RedisTemplate
发送 HTML 样式的邮件
之前也使用过,所以可以参考这篇文章:Java整合Spring发送邮件
一、引入依赖
<!-- mail -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、配置邮箱的参数
# mail
spring.mail.host=smtp.qq.com
spring.mail.port=465
spring.mail.username=xxxxxxxx
spring.mail.password=xxxxxxxx
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.debug=true
如果使用的是 QQ 邮箱,需要在邮箱的设置中获取授权码,填入上面的 password 中
三、写模板和发送内容
MailServiceImpl.java
@Autowired
private JavaMailSender javaMailSender;
@Override
public void sendHtmlMail(String from, String to, String subject, String content) {
try {
MimeMessage message = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(content, true);
javaMailSender.send(message);
} catch (MessagingException e) {
System.out.println("发送邮件失败");
log.error("发送邮件失败", e);
}
}
mailtemplate.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>邮件</title>
</head>
<body>
<div th:text="${subject}"></div>
<div>书籍清单
<table border="1">
<tr>
<td>图书编号</td>
<td>图书名称</td>
<td>图书作者</td>
</tr>
<tr th:each="book:${books}">
<td th:text="${book.id}"></td>
<td th:text="${book.name}"></td>
<td th:text="${book.author}"></td>
</tr>
</table>
</div>
</body>
</html>
test.java
@Autowired
private MailService mailService;
@Autowired
private TemplateEngine templateEngine;
@Test
public void sendThymeleafMail() {
Context context = new Context();
context.setVariable("subject", "图书清册");
List<Book> books = Lists.newArrayList();
books.add(new Book("Go 语言基础", 1, "nonename", BigDecimal.TEN));
books.add(new Book("Go 语言实战", 2, "nonename", BigDecimal.TEN));
books.add(new Book("Go 语言进阶", 3, "nonename", BigDecimal.TEN));
context.setVariable("books", books);
String mail = templateEngine.process("mailtemplate.html", context);
mailService.sendHtmlMail("xxxx@qq.com", "xxxxxxxx@qq.com", "图书清册", mail);
}
通过上面简单步骤,就能够在代码中发送邮件,例如我们每周要写周报,统计系统运行状态,可以设定定时任务,统计数据,然后自动化发送邮件。
整合 Swagger (API 文档)
一、引入依赖
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
二、配置 Swagger 参数
SwaggerConfig.java
@Configuration
@EnableSwagger2
@EnableWebMvc
public class SwaggerConfig {
@Bean
Docket docket() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("cn.sevenyuan.demo.controller"))
.paths(PathSelectors.any())
.build().apiInfo(
new ApiInfoBuilder()
.description("Spring Boot learn project")
.contact(new Contact("JingQ", "https://github.com/vip-augus", "=-=@qq.com"))
.version("v1.0")
.title("API 测试文档")
.license("Apache2.0")
.licenseUrl("http://www.apache.org/licenese/LICENSE-2.0")
.build());
}
}
设置页面 UI
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 60)
public class MyWebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
通过这样就能够识别 @ApiOperation 等接口标志,在网页查看 API 文档,参考文档:Spring Boot实战:集成Swagger2
总结
这边总结的整合经验,只是很基础的配置,在学习的初期,秉着先跑起来,然后不断完善和精进学习。
而且单一整合很容易,但多个依赖会出现想不到的错误,所以在解决环境问题时遇到很多坑,想要使用基础的脚手架,可以尝试跑我上传的项目。
数据库脚本在 resources 目录的 test.sql 文件中
相关推荐
- 人人视频崩了怎么回事 人人视频下架了吗为什么刷不出来了
-
[海峡网]人人视频挂了吗下架了吗人人视频崩了怎么回事刷不出来了?人人视频发生了什么?怎么都看不成了,暂时还是永久?本来还以为是手机的问题,原来是客户端崩了难怪一直显示服务器异常!追着的美剧突然都下架...
- 502 bad gateway怎么解决?(502 bad gatewaynginxundefined)
-
相信许多小伙伴都遇到打开的网页提示502badgateway,502badgateway是提示用户该网址的网关错误,Web服务器作为网关或代理服务器时收到无效的响应,不管怎么刷新怎么重新输入地...
- 2岁男童眼睛被滴入强酸药水,医生亲身“试”药吓坏了……
-
平日里,小孩子爱玩爱闹是常事儿,但是大人的注意力如果时不时的掉线可就麻烦了。这一天,杭师大附院眼科陈舒主任医师像往常一样在接诊病人,然而一个孩子的哭闹声引起了她的注意,一群人神情焦灼,簇拥着一个孩子急...
- 3岁男童误将502胶当滴眼液,幸好妈妈及时处理,医生也为她点赞
-
小孩子由于心智还不够成熟,因此往往会做出一些危险的事情,甚至对自己造成伤害,这就需要家长的监督和保护。巧也不巧,日常生活中能够对孩子造成威胁的东西实在是太多了,堪称数不胜数,水笔、筷子、桌角,甚至刚拖...
- 5岁娃把502胶当眼药水滴眼中,爸爸的做法很机智,医生都称赞
-
文|哑铃妈妈家里有小孩子的一定要注意,在我们的家里存在很多的安全隐患,有的时候连家长都想不到的东西,竟然对孩子带来了伤害。5岁娃把502胶当眼药水滴眼中,爸爸的做法很机智,医生都点赞女孩乐乐长得可爱,...
- 宝宝误食502胶水,连忙送医救治,医生却夸宝妈做得好
-
有了孩子之后,妈妈都会变得神经敏感,生怕自己没有把孩子照顾好,但是毕竟一个人的经历是有限的,再加上孩子要是会走路,会说话之后对宝妈来说更是一种挑战,危及可能无时无刻不存在,这不,因为宝妈一转身的功夫,...
- 记一次Netty「直接内存溢出」导致线上网关项目宕机排查过程
-
作为一名Java开发者,我们都知道Java进程是运行在Java虚拟机上的,而Java进程要想正常运行则需要向计算机申请内存,其中主要为Java对象实例所占用的堆(heap)内存(当然还有其他的也会占用...
- 刚刚,突然崩了!网易云音乐紧急回应
-
今天下午#网易云音乐崩了#登上微博热搜第一在社交平台上,不少网友反馈,网易云音乐疑似崩溃。网友晒出网页端出现“502BadGateway”的服务器错误,同时网易云音乐的移动应用程序也无法正常使用。...
- 常见状态码(常见的状态码)
-
一二三四五原则:(即一:消息系列;二:成功系列;三:重定向系列;四:请求错误系列;五:服务器端错误系列。301状态码是永久移动302是临时移动304如果请求头中带有If-None-Match...
- 8岁男孩眼睛溅入502胶水,妈妈一番操作结果粘得更紧了
-
家有小孩的爸妈们肯定会多留个心眼照看虽然生活中已经时刻留意可能造成伤害的物品但有时一不留神幼小的孩子就会做出让人担心的事↓↓↓家住深圳的辰辰(化名)今年8岁了3月31日他在家里做手工时想要用未开封的5...
- 3岁娃滴502胶水在眼睛疼的尖叫,宝妈急中生智,保住孩子眼睛
-
但还好宝妈急中生智,连忙将孩子带到水龙头处,用水给孩子冲洗了一下眼睛,还用大量的生理盐水来给孩子清洗眼球,之后又立马将孩子送往医院,最后孩子的眼睛也没有什么大碍,拿了点药就能顺利出院了。而502胶水这...
- 网易云音乐回应App崩了:故障已陆续修复,补偿7天会员
-
2024年8月19日下午,多名网友反馈称,网易云音乐服务器疑似出现故障,登录网易云音乐APP后发现,个性化推荐和搜索功能均无法使用,并收到“获取数据失败”的提示。此外,网易云音乐的网页端也显示502错...
- 又崩了!不少人直接傻眼:太离谱!(台湾人到大陆后傻眼)
-
造车新势力哪吒汽车再被推向舆论风口。5月4日,话题#曝哪吒汽车APP断网#冲上微博热搜App断网无法使用从5月2日开始,陆续有多位网友反映哪吒汽车App断网,App控车无法使用。哪吒汽车App目前出现...
- 男子误把502胶水当眼药水!千万别犯这种低级错误!
-
你敢相信吗?有人竟然误把五零二胶水当成了眼药水滴进眼睛里。这可不是什么玩笑话,而是近日发生在武汉的一起真实事件。一名男子因此导致眼角膜严重受损,不得不紧急就医。据武汉大学附属爱尔眼科医院报道,这名男子...
- 502入眼危机!这份急救指南请牢记(502进入眼中怎么办)
-
502入眼,真实案例触目惊心生活中,502胶水是常用的黏合剂,以其强力黏合性备受青睐。但它一旦进入眼睛,后果不堪设想,下面这些真实案例,足以让我们警醒。曾有这样一则新闻,一位4岁女童在家玩耍时...
你 发表评论:
欢迎- 一周热门
-
-
UOS服务器操作系统防火墙设置(uos20关闭防火墙)
-
极空间如何无损移机,新Z4 Pro又有哪些升级?极空间Z4 Pro深度体验
-
如何修复用户配置文件服务在 WINDOWS 上登录失败的问题
-
手机如何设置与显示准确时间的详细指南
-
如何在安装前及安装后修改黑群晖的Mac地址和Sn系列号
-
日本海上自卫队的军衔制度(日本海上自卫队的军衔制度是什么)
-
10个免费文件中转服务站,分享文件简单方便,你知道几个?
-
爱折腾的特斯拉车主必看!手把手教你TESLAMATE的备份和恢复
-
NAS:DS video/DS file/DS photo等群晖移动端APP远程访问的教程
-
FANUC 0i-TF数据备份方法(fanuc系统备份教程)
-
- 最近发表
- 标签列表
-
- linux 查询端口号 (58)
- docker映射容器目录到宿主机 (66)
- 杀端口 (60)
- yum更换阿里源 (62)
- internet explorer 增强的安全配置已启用 (65)
- linux自动挂载 (56)
- 禁用selinux (55)
- sysv-rc-conf (69)
- ubuntu防火墙状态查看 (64)
- windows server 2022激活密钥 (56)
- 无法与服务器建立安全连接是什么意思 (74)
- 443/80端口被占用怎么解决 (56)
- ping无法访问目标主机怎么解决 (58)
- fdatasync (59)
- 405 not allowed (56)
- 免备案虚拟主机zxhost (55)
- linux根据pid查看进程 (60)
- dhcp工具 (62)
- mysql 1045 (57)
- 宝塔远程工具 (56)
- ssh服务器拒绝了密码 请再试一次 (56)
- ubuntu卸载docker (56)
- linux查看nginx状态 (63)
- tomcat 乱码 (76)
- 2008r2激活序列号 (65)