avatar
文章
360
标签
49
分类
10
首页
时间轴
分类
关于
Logo只有那年胜过年年
搜索
首页
时间轴
分类
关于

只有那年胜过年年

Spring Boot 注册 Servlet 的三种方法,真是太有用了!
发表于2025-10-29|后端
本文栈长教你如何在 Spring Boot 注册 Servlet、Filter、Listener。 一、Spring Boot 注册Spring Boot 提供了 ServletRegistrationBean, FilterRegistrationBean, ServletListenerRegistrationBean 三个类分别用来注册 Servlet, Filter, Listener,下面是 Servlet 的示例代码。 import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * */ public class RegisterServlet extends HttpServlet { @Override protected void service(Http...
Spring Boot 的 10 个核心模块
发表于2025-10-29|后端
学习 Spring Boot 必须得了解它的核心模块,和 Spring 框架一样,Spring Boot 也是一个庞大的项目,也是由许多核心子模块组成的。 Spring Boot 的核心模块下面我们大概来了解一下 Spring Boot 的核心模块。 1、spring-boot 这是 Spring Boot 的主模块,也是支持其他模块的核心模块,主要包含以下几点: 提供了一个启动 Spring 应用的主类,并提供了一个相当方便的静态方法,它的主要是作用是负责创建和刷新 Spring 容器的上下文; 内嵌式的并可自由选择搭配的 WEB 应用容器,如:Tomcat, Jetty, Undertow等; 对配置外部化的支持; 提供一个很方便的 Spring 容器上下文初始化器,包括合理记录日志默认参数的支持。 2、spring-boot-autoconfigure Spring Boot能根据类路径下的内容自动一些公共大型应用,提供的 @EnableAutoConfiguration 注解就能启用 Spring 功能的自动配置。 自动配置功能可以推断用户可能需要加载哪些 S...
Spring Boot 是什么?
发表于2025-10-29|后端
什么是Spring Boot?Spring Boot是Spring开源组织下的子项目,是Spring组件一站式解决方案,主要是简化了使用Spring的难度,简省了繁重的配置,提供了各种启动器,开发者能快速上手。 官方网站:http://projects.spring.io/spring-boot/\GitHub源码:https://github.com/spring-projects/spring-boot Spring Boot的优点Features Create stand-alone Spring applications Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files) Provide opinionated ‘starter’ POMs to simplify your Maven configuration Automatically configure Spring whenever possible Provide production-ready features s...
Spring Boot 自动配置原理、实战
发表于2025-10-29|后端
Spring Boot自动配置原理Spring Boot的自动配置注解是@EnableAutoConfiguration,从上面的@Import的类可以找到下面自动加载自动配置的映射。 org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Class<?>, ClassLoader) public static List<String> loadFactoryNames(Class<?> factoryClass, ClassLoader classLoader) { String factoryClassName = factoryClass.getName(); try { Enumeration<URL> urls = (classLoader != null ? classLoader.getResources(FACTORIES_RESOURCE_LOCATION) ...
Spring Boot 读取配置的几种方式
发表于2025-10-29|后端
读取application文件在application.yml或者properties文件中添加: info.address=USAinfo.company=Springinfo.degree=high @Value注解读取方式 import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class InfoConfig1 { @Value("${info.address}") private String address; @Value("${info.company}") private String company; @Value("${info.degree}") private String degre...
Spring Boot 自定义日志详解
发表于2025-10-29|后端
本节内容基于 Spring Boot 2.0. Spring Boot 日志综合介绍Spring Boot 内部代码使用的是 commons-logging 来记录日志的,但是底层日志实现框架是可以随意替换的。Spring Boot为 Java Util Logging, Log4J2, 和 Logback 日志框架提供了默认配置。 Spring Boot支持的日志框架默认配置如下。 # LOGGING logging.config= # Location of the logging configuration file. For instance, `classpath:logback.xml` for Logback. logging.exception-conversion-word=%wEx # Conversion word used when logging exceptions. logging.file= # Log file name (for instance, `myapp.log`). Nam...
Spring Boot 运行应用的 3 种方式
发表于2025-10-29|后端
今天介绍 3 种运行 Spring Boot 应用的方式,看大家用过几种? 运行 Spring Boot 应用的 3 种方式1、在 IDE 中运行在 Eclipse、IDEA 中直接运行,又有以下两种方式。 jar 包方式 Spring Boot 默认采用 jar 包内嵌 Tomcat、Jetty 等 Server 的方式,并需要提供一个含有 main 方法的主类。这个时候,直接在 IDE 中运行这个 main 方法就能启动 Spring Boot 应用了。 war 包方式 如果你的应用改装成了 war 包方式部署,这个时候就需要在 IDE 中配置 Server,然后在 Server 中加入你的 Spring Boot 项目,最后运行这个 Server 即可。 如何改装成 war 包方式运行请看这篇文章《Spring Boot 发布 jar 包转为 war 包秘籍》 2、打包运行当你的 Spring Boot 准备提测或者上线,都需要打成 jar 包或者 war 包运行,war 包方式这里不说直接丢到 Server 里面运行即可,这里介绍直接运行 jar 包的方式。 ...
Spring Boot 返回 JSON 数据,一分钟搞定!
发表于2025-10-29|后端
在 WEB 项目中返回 JSON 数据是常见的交互形式,在 Spring Boot 中这一切都变得十分简单。So easy!!! 如何返回 JSON 数据?在 Spring Boot 中返回 JSON 数据很简单,如下几步。 加入依赖<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.4.RELEASE</version> </parent> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </de...
Spring Boot 配置加载顺序
发表于2025-10-29|后端
如果加载的配置有重复的,它们的加载顺序是这样的,数字越小的优先级越高,即优先级高的覆盖优先级低的配置。 Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active). @TestPropertySource annotations on your tests. @SpringBootTest#properties annotation attribute on your tests. Command line arguments. Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property) ServletConfig init parameters. ServletContext init parameters. JNDI attribu...
Spring Boot 返回 XML 数据,一分钟搞定!
发表于2025-10-29|后端
Spring Boot 返回 XML 数据,前提必须已经搭建了 Spring Boot 项目,所以这一块代码就不贴了,可以点击查看之前分享的 Spring Boot 返回 JSON 数据,一分钟搞定!。 如何返回 XML 数据?那么如何返回 XML 格式数据呢?其实很简单! 加入 XML 工具依赖<dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> </dependency> 不用带版本号,因为在 spring-webmvc 包中已经定义好了,只是没有把依赖传递过来而已,如下面源码所示。 <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifact...
1…232425…36
avatar
2025
文章
360
标签
49
分类
10
公告
🌸 春去秋来,花开花落 📚 桌上的日历又薄了几页 💭 记忆中的昨天还那么清晰
最新文章
掌握 Spring 框架这 10 个扩展点,开发效率直接翻倍2025-11-10
Minikube安装教程2025-11-07
Deepseek 本地部署各个版本超级详细教学,网页版、软件版2025-11-04
Slow HTTP POST 慢速攻击2025-10-30
JDK 紧急漏洞,XMLDecoder反序列化攻击2025-10-30
分类
  • 其他3
  • 区块链4
  • 后端225
  • 安全漏洞3
  • 工具30
  • 性能4
  • 教程1
  • 数据库21
  • 架构15
  • 程序人生54
标签
文章LinuxJVM分布式技术其他区块链基础安全漏洞多线程性能优化新特性架构算法程序人生行业动态规范资料集合进阶面试Elastic JobdockerJWTDubboMyBatisNettyShiroSpringSpring MVCSpring CloudTomcatSpring BootZookeeper日志开源综合技术消息队列缓存连接池Eclipse
归档
  • 2025年11月 3
  • 2025年10月 355
  • 2025年09月 1
  • 2024年12月 1
网站信息
文章数目 :
360
本站访客数 :
本站总浏览量 :
最后更新时间 :
访客地图
© 2025 By 2025
搜索
数据加载中