springboot项结构分析

本文为博客 VIP 文章,开通 VIP 后可阅读全文

开通 VIP

三. SpringBoot 结构

3.1.SpringBoot 工作原理

Spring boot应用程序采用各种Starters启动器,入口类是包含@SpringBootApplication注解和main方法的类,然后使用@ComponentScan注解自动扫描项目中的所有组件,并且Spring Boot会根据@EnableAutoConfiguration注解将项目中的依赖项自动配置到应用程序中.例如,如果MySQL数据库在类路径上,但尚未配置任何数据库连接,则Spring Boot会自动配置内存数据库.

3.2 SpringBoot入口类

Spring Boot应用程序的入口点是包含@SpringBootApplication注解的类,该类中包含运行Spring Boot应用程序的main方法.默认一般是一个* application 结尾。

@SpringBootApplication注解包括自动配置,组件扫描和Spring Boot配置.
如果将@SpringBootApplication注解添加到类中,则无需添加@EnableAutoConfiguration,@ComponentScan和@SpringBootConfiguration注解.@SpringBootApplication注解包括其他所有的注解.

3.3 常见注解

1 @SpringBootApplication
@SpringBootApplication注解是Spring Boot的核心注解,用于标注程序是一个springboot 程序,它是一个组合注解,由多个注解组合而成
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = {
   
   
		@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
		@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
   
   
  //此处忽略接口内部内容
}
2 @SpringBootConfiguration注解
@SpringBootConfiguration注解可以用Java代码的形式实现spring中xml配置文件配置的效果。也就是用来加载配置文件。
@Target({
   
   ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
public @interface SpringBootConfiguration {
   
   
}
3 @EnableAutoConfiguration注解
启用自动配置,该注解会使Spring Boot根据项目中依赖的jar包自动配置项目的配置项,这也是 springboot 的核心注解之一,我们只需要将项目需要的依赖包导入进来,它会自动帮我们配置这个依赖需要的基本配置
比如我们的项目引入了spring-boot-starter-web依赖,springboot 会自动帮我们配置 tomcat 和 springmvc
4 @ComponentScan 注解
默认扫描@SpringBootApplication类所在包的同级目录以及它的子目录。用来扫描组件和自动装配。

springboot 支持的自动配置可以查看到

在spring-boot-autoconfigure包中包含了支持的自动装配依赖,截图只是其中一部分,我们开发中常见的依赖都做了基本配置

在这里插入图片描述

在这里插入图片描述

3.4 Springboot 全局配置文件

1.格式

​ SpringBoot使用的全局配置文件有两种格式:

​ • application.properties

​ • application.yml

​ 虽然后缀不一样,但是项目中有一个就可以了,yml格式比properties格式的简洁一些。

​ 这个文件的位置在配置文件放在src/main/resources目录或者类路径/config下。

  properties 和 .yml,它们的区别主要是书写格式不同。
    1).properties
      server.port=8088
      server.servlet.context-path=/testboot
    2).yml
    server:
      port: 8088
      servlet:
        context-path: /testboot
    另外yml 格式不支持 @PropertySource 注解导入配置 
    :和值之间有一个空格
2.作用

​ 全局配置文件的作用是:可以对一些默认配置值进行修改。

3.5 starter 启动器

springboot 提供了很多 starter, 可以帮我们快速构建相应的开发环境,导入相关的依赖,并设置相关配置

Name Description Pom
spring-boot-starter Core starter, including auto-configuration support, logging and YAML 核心启动器,包括自动配置,日志以及 YAML 支持 Pom
spring-boot-starter-activemq Starter for JMS messaging using Apache ActiveMQ 对Apache ActiveMQ提供支持 Pom
spring-boot-starter-amqp Starter for using Spring AMQP and Rabbit MQ 对Spring AMQP 和 Rabbit MQ支持 Pom
spring-boot-starter-aop Starter for aspect-oriented programming with Spring AOP and AspectJ 对 spring AOP和AspectJ提供支持 Pom
spring-boot-starter-artemis Starter for JMS messaging using Apache Artemis 对Apache Artemis提供支持 Pom
spring-boot-starter-batch Starter for using Spring Batch Pom
spring-boot-starter-cache Starter for using Spring Framework’s caching support Pom
spring-boot-starter-cloud-connectors Starter for using Spring Cloud Connectors which simplifies connecting to services in cloud platforms like Cloud Foundry and Heroku Pom
spring-boot-starter-data-cassandra Starter for using Cassandra distributed database and Spring Data Cassandra Pom
spring-boot-starter-data-cassandra-reactive Starter for using Cassandra distributed database and Spring Data Cassandra Reactive Pom
spring-boot-starter-data-couchbase Starter for using Couchbase document-oriented database and Spring Data Couchbase Pom
spring-boot-starter-data-couchbase-reactive Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive Pom
spring-boot-starter-data-elasticsearch Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch Pom
spring-boot-starter-data-jpa Starter for using Spring Data JPA with Hibernate Pom
spring-boot-starter-data-ldap Starter for using Spring Data LDAP Pom
spring-boot-starter-data-mongodb Starter for using MongoDB document-oriented database and Spring Data MongoDB Pom
spring-boot-starter-data-mongodb-reactive Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive Pom
spring-boot-starter-data-neo4j Starter for using Neo4j graph database and Spring Data Neo4j Pom
spring-boot-starter-data-redis Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client Pom
spring-boot-starter-data-redis-reactive Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client Pom
spring-boot-starter-data-rest Starter for exposing Spring Data repositories over REST using Spring Data REST Pom
spring-boot-starter-data-solr Starter for using the Apache Solr search platform with Spring Data Solr Pom
spring-boot-starter-freemarker Starter for building MVC web applications using FreeMarker views Pom
spring-boot-starter-groovy-templates Starter for building MVC web applications using Groovy Templates views Pom
spring-boot-starter-hateoas Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS Pom
spring-boot-starter-integration Starter for using Spring Integration Pom
spring-boot-starter-jdbc Starter for using JDBC with the Tomcat JDBC connection pool Pom
spring-boot-starter-jersey Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to spring-boot-starter-web Pom
spring-boot-starter-jooq Starter for using jOOQ to access SQL databases. An alternative to spring-boot-starter-data-jpa or spring-boot-starter-jdbc Pom
spring-boot-starter-json Starter for reading and writing json Pom
spring-boot-starter-jta-atomikos Starter for JTA transactions using Atomikos Pom
spring-boot-starter-jta-bitronix Starter for JTA transactions using Bitronix Pom
spring-boot-starter-jta-narayana Spring Boot Narayana JTA Starter Pom
spring-boot-starter-mail Starter for using Java Mail and Spring Framework’s email sending support Pom
spring-boot-starter-mustache Starter for building web applications using Mustache views Pom
spring-boot-starter-quartz Spring Boot Quartz Starter Pom
spring-boot-starter-security Starter for using Spring Security Pom
spring-boot-starter-test Starter for testing Spring Boot applications with libraries including JUnit, Hamcrest and Mockito Pom
spring-boot-starter-thymeleaf Starter for building MVC web applications using Thymeleaf views Pom
spring-boot-starter-validation Starter for using Java Bean Validation with Hibernate Validator Pom
spring-boot-starter-web Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container Pom
spring-boot-starter-web-services Starter for using Spring Web Services Pom
spring-boot-starter-webflux Starter for building WebFlux applications using Spring Framework’s Reactive Web support Pom
spring-boot-starter-websocket Starter for building WebSocket applications using Spring Framework’s WebSocket support Pom

附录 springboot 全局配置属性

# ===================================================================
# COMMON SPRING BOOT PROPERTIES
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application.               ^^^
# ===================================================================


# ----------------------------------------
# CORE PROPERTIES
# ----------------------------------------

# BANNER
banner.charset=UTF-8 # Banner file encoding.
banner.location=classpath:banner.txt # Banner file location.
banner.image.location=classpath:banner.gif # Banner image file location (jpg/png can also be used).
banner.image.width= # Width of the banner image in chars (default 76)
banner.image.height= # Height of the banner image in chars (default based on image height)
banner.image.margin= # Left hand image margin in chars (default 2)
banner.image.invert=
springboot 项目结构简单分析 本文档为个人博客文档系统的备份版本、作者:小游、作者博客:点击访问 先来看一下项目结构 java里面主要是放着控制代码,然后resource里面放的是资源文件 其中application.yml 存放的是各种配置文件(比如mysql数据库连接的账号和密码) 关于mybatis 这个是一个 数据库的连接的持久化框架,使用它可以不必使用麻烦的jdbc代码,我们只需通过简单的xml或者注解即可达到目的。 通过下面这个地方来指定模型层 我们可以使用javabean来指定模型层,当然还有set,get方法。这. 阅读详情

相关推荐

基于 YOLO + SAM 的自动图像标注实战

摘要: 本文提出一种基于YOLO检测和SAM分割的自动化数据标注流水线方案,通过YOLO定位目标并生成检测框,再以检测框为提示驱动SAM完成精细分割,最终输出YOLO格式的标注文件。该方案将人工标注升级为半自动流程,显著提升标注效率,尤其适用于多类别、大规模图像的实例级标注需求。代码模块化设计支持模型灵活替换,并集成异常处理与进度可视化功能。虽依赖YOLO检测质量且对小目标存在局限,但作为工程落地方案,可有效降低私有数据集构建成本,适用于工业检测、遥感等场景的冷启动标注。

qq_64366203的博客 1095

Spring Boot项目结构

目录Spring Boot项目结构一、代码层结构二、资源目录结构三、测试测序目录结构四、项目结构示例 Spring Boot项目结构 一、代码层结构 根目录:src/main/java 入口启动类及程序的开发目录。在这个目录下进行业务开发、创建实体层、控制器层、数据连接层等。 启动类CloudCustomerServiceApplication.java推荐放在src/main/java/com.user下 数据库实体层pojo model层即数据库实体层,也被称为entity层,pojo

weixin_44814196的博客 2万+

论文理解【LLM-OR】——【OptiMUS】Scalable Optimization Modeling with (MI)LP Solvers and Large Language Models

OptiMUS 把“自然语言→优化建模与求解”从单次生成改造成“结构化问题 + 多智能体协作 + 连接图检索”的模块化流程,并在更长更难的数据集上验证了这种结构化方法相对端到端 prompting 的优

佚失的诗篇 763

springboot项目结构

一,代码层结构 domain: 数据库实体类(也有使用pojo和entity) dao: 数据接口访问层 service: 数据服务接口层 impl: 数据服务接口实现层 controller: 控制层 utils: 工具类 config: 配置类 dto: 数据传输对象 数据传输对象(Data Transfer Object)用于封装多个实体类domain之间的关系,不破坏原有的实体类结构 vo: 视图包装对象 视图包装对象(View Object)用于封装客户端请求的数据,防止部分数据泄露如:管理员I

斧头湖懒客 4277

SpringBoot

第一章 JavaConfig 为什么要使用 Spring Boot 因为SpringSpringMVC 需要使用的大量的配置文件 (xml文件,还需要配置各种对象,把使用的对象放入到spring容器中才能使用对象,需要了解其他框架配置规则。 SpringBoot 就相当于 不需要配置文件的Spring+SpringMVC。 常用的框架和第三方库都已经配置好了。拿来就可以使用了。 SpringBoot开发效率高,使用方便多了 1.1 JavaConfig JavaConfig: 使用java类作为x

weixin_44484668的博客 1430

Springboot项目结构

_annotation:放置项目自定义注解|_aspect:放置切面代码|_config:放置配置类|_constant:放置常量、枚举等定义|__consist:存放常量定义|__enums:存放枚举定义|_controller:放置控制器代码|_filter:放置一些过滤、拦截相关的代码|_mapper:放置数据访问层代码接口|_model:放置数据模型代码|__entity:放置数据库实体对象定义|__dto:存放数据传输对象定义|__vo:存放显示层对象定义。

weixin_46356448的博客 2541

Spring Boot项目结构

Spring Boot项目结构遵循Maven或Gradle的标准目录结构,同时融入了Spring Boot的特定约定。良好的项目结构不仅有助于代码组织,还能提高开发效率和项目可维护性。了解Spring Boot项目结构对于开发高质量的应用至关重要。

weixin_52938153的博客 2431

初始SpringBoot:详解特性和结构

SpringBoot项目结构,特性介绍(常用到的基本都讲解了,很详细,基于官方文档讲解)。以上就是SpringBoot的特性及结构的具体讲解。

m0_74824091的博客 670

2 如何分析SpringBoot源码模块及结构

其子pom为spring-boot-project(pom.xml)的子module(注意除去spring-boot-dependencies(pom.xml)),比如有spring-boot(pom.xml),spring-boot-starters(pom.xml)和spring-boot-actuator(pom.xml)等;●spring-boot-project(pom.xml)起到聚合module的作用,其子模块并不继承于它,而是继承于spring-boot-parent(pom.xml);

CoderChronicle的博客 1080

SpringBoot项目目录结构(工程结构

一、代码层结构 根目录:com.bajins 1.启动类CsdnApplication.java推荐放在根目录com.bajins包下 2.实体类domain jpa项目: com.bajins.domain mybatis项目: com.bajins.pojo 3.数据接口访问层(Dao) jpa项目: com.bajins.repository mybatis...

Claer_XX的博客 9万+

springboot框架 目录结构

目录结构 src/main/java:主程序入口 Application,可以通过直接运行该类来 启动 Spring Boot应用 src/main/resources:配置目录,该目录用来存放应用的一些配置信息,比如应用名、服务端口、数据库配置等。由于我们应用了Web模块,因此产生了 static目录与templates目录,前者用于存放静态资源,如图片、CSS、JavaScript等;后...

在杯子里放零食的博客 6万+

SpringBoot中通过8配置优化提升Tomcat性能

SpringBoot中通过8配置优化提升Tomcat性能

码到三十五 1万+

【知识】SpringBoot项目结构目录

Spring boot 目录结构 一、主要目录 目录名称 相对路径 主要用途 源码目录 src\main\java 存储源码 资源目录 src\main\resources 存储静态资源、动态页面、配置文件 测试目录 src\test\java 存储单元测试、测试程序 java目录是进行编程和开发的主要目录,业务逻辑代码在这里完成。 DemoApplication.java 入门口类 在生成的springboot项目中有一个入口类,需要添加注解@SpringBootAppli

请你喝杯Java 1万+

springboot目录结构分析-苍穹外卖

这是一个典型的picturesky-commonsky-pojoUserOrdersky-server.gitignoreREADME.mdpom.xml该目录结构体现了的思想,将通用工具、依赖管理、实体类和业务逻辑分离,便于项目的维护和扩展。

Violet_YSWY的博客 678

SpringBoot jar包内容结构分析小结

解压后,像是上面这种文件结构,才是正确的springboot启动包,如果不是,可能是没有配置springboot的maven打包插件;有时候定位一些问题可能需要从jar包里分析,比如是否正确生成了springboot的启动包,二/三方库依赖版本号是否符合预期等。: 这些是其他应用程序可能包含的文件和目录,例如静态资源文件、配置文件、日志文件等。: 这个目录包含了 Spring Boot 应用程序的运行时内容。: 这个目录包含了应用程序的依赖库和类文件。: 这个目录包含了 JAR 文件的元信息。

weixin_38687619的博客 943

SpringBoot : 一个较完整的SpringBoot项目的目录结构

以前已经聊过如果快速创建Spring Boot基础项目。今天来搞一个较为完整的SpringBoot项目。 下面是我创建的一个Spring Boot项目 src下main:存放的是代码源文件,java、xml、proeprties等 src下test:通常是我们做单元测试的时候使用。 controller:此目录主要是存放**Controllerde ,比如:UserController.java,也有的项目是把action放在controller目录下,有的是把UserController.

qq_31432773的博客 5万+

如何分析SpringBoot源码模块及结构?--SpringBoot源码(二)

注:该源码分析对应SpringBoot版本为2.1.0.RELEASE 1 前言 本篇接 如何搭建自己的SpringBoot源码调试环境?–SpringBoot源码(一)。 前面搭建好了自己本地的SpringBoot源码调试环境后,此时我们不要急着下手进入到具体的源码调试细节中,刚开始阅读源码,此时我们一定要对项目结构等有一个整体的认识,然后再进行源码分析调试。推荐阅读下笔者之前写的的分析开源项目...

biaolianlao0449的博客 1491

springboot目录结构

springboot目录结构简介结构总结 简介 经过上次考核的洗礼,越发认识到项目目录结构的重要性,所以这次在学习springboot时便首先了解了springboot的目录结构,经过我不懈努力,终于得到了一个清晰的答案。 结构 1.src/main/java 这个是必不可少的java代码存放的地方 2.src/main/resource 这个就很重要,这儿不仅仅是存放各种配置文件的地方了,还被用来存放前端的html页面,css,js等静态资源 resource中首先要存放的就是application.p

天青色 等烟雨的博客 8911

托盘实例分割数据集_20251120_043045.zip

托盘实例分割数据集一、基础信息数据集名称:托盘实例分割数据集图片数量:- 训练集:507张图片- 验证集:101张图片- 测试集:68张图片- 总计:676张图片分类类别:- palletfront(托盘正面):托盘的正面视图部分,用于识别托盘的方向和整体结构。- palletpocket(托盘口袋):托盘上的口袋或凹槽结构,常用于堆叠或固定时的定位。标注格式:YOLO格式,包含实例分割的多边形坐标点,适用于实例分割任务。数据格式:JPEG图片,来源于实际物流和工业场景。二、适用场景物流自动化系统开发:数据集支持实例分割任务,帮助构建能够精确识别和分割托盘部件的AI模型,实现自动化的堆叠、分类和库存管理。工业机器人视觉集成:集成至机器人控制系统,提供准确的托盘部件分割结果,指导机器人进行抓取、放置和操作。制造业质量检测:用于检测托盘的结构完整性和正确性,确保在生产和物流过程中的质量评估。学术研究与算法创新:支持计算机视觉实例分割算法的研究和开发,特别是在工业应用场景下的性能提升。三、数据集优势精准标注与实用性:每个托盘实例都经过详细的多边形标注,确保分割边界的准确性,直接适用于实际应用。类别覆盖关键部件:包含托盘正面和口袋两个重要类别,覆盖托盘结构中的关键元素,提升模型的综合识别能力。格式兼容与易用性:标注采用主流YOLO格式,兼容多种深度学习框架,便于快速加载和训练。真实场景数据:图片来源于真实环境,具有高度的实际代表性,增强模型在现实世界中的泛化能力。应用价值突出:专注于物流和工业领域的实例分割需求,为自动化系统提供可靠的数据支撑。

上一篇: springboot项目搭建
下一篇: Spring Boot中添加Thymeleaf模板
Java-呆萌老师
博客等级 码龄4年 150粉丝 170原创
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值