feat: add four dependency-based example modules (kafka, mail, elasticsearch, flyway) - #46
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
在上一轮「无需外部服务的示例」基础上,补齐 4 个带真实第三方依赖的示例模块。每个模块的运行时依赖都已明确(Kafka / SMTP / Elasticsearch / MySQL),但测试全部可离线跑通,不依赖 Docker 或外部服务,因此 CI 上
mvn clean install依然能稳定通过。新增模块
kafkaKafkaTemplate生产 +@KafkaListener消费@EmbeddedKafka内嵌 brokermailSimpleMailMessage/MimeMessageHelper发邮件elasticsearchflywaydb/migration迁移脚本 +JdbcTemplate读取测试
全量
mvn clean install通过,30 个模块全部 SUCCESS。本次新增 5 个测试(kafka 1 + mail 2 + flyway 2),修复了 1 个 flaky 测试:actuator健康检查测试:原先的DiskSpaceRatioHealthIndicator依赖真实磁盘剩余空间,磁盘快满时/actuator/health会返回 503 导致测试随机失败。现把阈值改为可配置(actuator.disk-space-ratio.threshold),测试里设成 0 使判定确定性地为 UP。Spring Boot 4 下的注意点
spring-kafka或flyway-core拿不到自动配置,必须用spring-boot-starter-kafka/spring-boot-starter-flyway。HibernateJpaAutoConfiguration外还要排除DataJpaRepositoriesAutoConfiguration,否则core传递引入的 spring-data-jpa 会尝试创建entityManagerFactory。spring.mail.properties.mail.smtp.auth/starttls设 false 并清空用户名密码,且purgeEmailFromAllMailboxes()抛受检异常需声明。