news 2026/4/18 10:37:08

Spring Boot 排除自动配置

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Spring Boot 排除自动配置
Spring Boot 排除自动配置

Spring Boot 自动配置非常强大,有时需要排除/禁用 Spring Boot 某些类的自动化配置。

*************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
方式1

@SpringBootApplication注解使用时,使用exclude属性进行排除指定的类:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class Application { // ... }

当自动配置类不在类路径下时,使用excludeName属性进行排除指定的类名全路径:

@SpringBootApplication(excludeName = {"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration"}) public class Application { // ... }
方式2

配置文件中指定参数spring.autoconfigure.exclude进行排除:

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

spring.autoconfigure.exclude[0]=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration spring.autoconfigure.exclude[1]=org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration

spring: autoconfigure: exclude: - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration - org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/18 3:38:00

翻译一致性保障:HY-MT1.5上下文记忆机制

翻译一致性保障:HY-MT1.5上下文记忆机制 1. 引言:翻译模型的上下文挑战与HY-MT1.5的突破 随着全球化进程加速,跨语言交流需求激增,机器翻译已从“能翻”迈向“翻得准、翻得连贯”的新阶段。传统翻译模型在处理长文本或多轮对话时…

作者头像 李华
网站建设 2026/4/18 3:37:58

混元翻译1.5术语库同步方案:多团队协作流程

混元翻译1.5术语库同步方案:多团队协作流程 随着全球化业务的加速推进,跨语言协作已成为研发、产品和运营团队的常态。在这一背景下,高质量、一致性的翻译能力成为提升协作效率的关键。腾讯开源的混元翻译模型 HY-MT1.5 系列,凭借…

作者头像 李华
网站建设 2026/4/18 3:26:08

HY-MT1.5模型服务监控:Prometheus集成

HY-MT1.5模型服务监控:Prometheus集成 1. 引言 随着大模型在实际业务场景中的广泛应用,模型服务的稳定性与可观测性成为工程落地的关键挑战。腾讯开源的混元翻译大模型HY-MT1.5系列(包括HY-MT1.5-1.8B和HY-MT1.5-7B)凭借其卓越的…

作者头像 李华
网站建设 2026/4/18 3:26:06

Spring Boot 3.x 系列【3】Spring Initializr快速创建Spring Boot项目

有道无术,术尚可求,有术无道,止于术。 本系列Spring Boot版本3.0.3 源码地址:https://gitee.com/pearl-organization/study-spring-boot3 文章目录 前言安装JDK 17创建Spring Boot 项目 方式1:网页在线生成方式2&#…

作者头像 李华
网站建设 2026/4/18 3:26:42

usb serial port 驱动下载:新手项目应用前必学基础

从“未知设备”到串口通信:新手必须掌握的USB转串调试全解析 你有没有遇到过这样的场景? 手里的开发板连上电脑,打开设备管理器——结果只看到一个孤零零的“ 未知设备 ”。Arduino IDE提示“端口不可用”,烧录失败&#xff1…

作者头像 李华
网站建设 2026/4/18 3:29:32

混元翻译1.5部署:多云架构高可用方案

混元翻译1.5部署:多云架构高可用方案 随着全球化进程加速,高质量、低延迟的机器翻译需求日益增长。传统集中式翻译服务在面对跨区域、高并发场景时,常面临网络延迟高、容灾能力弱、扩展性差等问题。为应对这些挑战,腾讯开源了混元…

作者头像 李华