news 2026/2/6 8:28:00

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/2/5 20:45:44

Spring BOOT 启动参数

Spring BOOT 启动参数 在Java Web的开发完成后,以前我们都会打包成war文件,然后放大web容器,比如tomcat、jetty这样的容器。现在基于SpringBoot开发的项目,我们直接打包成jar文件,基于内嵌的tomcat来实现一样的效果。 …

作者头像 李华
网站建设 2026/2/5 17:46:53

HY-MT1.5-7B混合语言场景优化实战教程

HY-MT1.5-7B混合语言场景优化实战教程 1. 引言:腾讯开源的混元翻译大模型 随着全球化进程加速,跨语言交流需求激增,高质量、低延迟的机器翻译技术成为AI应用的核心基础设施之一。在此背景下,腾讯推出了混元翻译模型1.5版本&…

作者头像 李华
网站建设 2026/2/5 15:55:33

多语言电商集成HY-MT1.5:商品描述自动翻译

多语言电商集成HY-MT1.5:商品描述自动翻译 随着跨境电商的迅猛发展,多语言商品描述的高效、准确翻译成为平台运营的关键环节。传统商业翻译API虽具备一定能力,但在成本、定制化和边缘部署方面存在明显瓶颈。腾讯开源的混元翻译大模型 HY-MT1…

作者头像 李华
网站建设 2026/2/4 22:32:10

混元翻译1.5行业应用:医疗法律专业翻译案例

混元翻译1.5行业应用:医疗法律专业翻译案例 1. 引言:混元翻译模型的演进与行业价值 随着全球化进程加速,跨语言沟通在医疗、法律、金融等专业领域的重要性日益凸显。传统通用翻译模型在面对高度专业化术语、复杂句式结构和上下文依赖性强的文…

作者头像 李华
网站建设 2026/2/4 16:40:51

HY-MT1.5-7B格式化输出:技术文档翻译实践

HY-MT1.5-7B格式化输出:技术文档翻译实践 1. 引言:腾讯开源的混元翻译大模型 随着全球化进程加速,高质量、多语言互译能力成为企业出海、科研协作和内容本地化的关键基础设施。在这一背景下,腾讯推出了混元翻译模型1.5版本&…

作者头像 李华