HertzBeat fails to start when spring.mail is omitted (docs say optional)
- Dominant language
- Java
- Stars
- 7.4k
- Forks
- 1.3k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 32
Description
## Problem
Docs and sample `application.yml` / docker-compose configs describe `spring.mail` as optional (“not required if you don’t use email notify”). In practice, HertzBeat **fails to start** when `spring.mail` is omitted.
On `apache/hertzbeat:1.8.0`, startup dies with:
```
Parameter 0 of constructor in
org.apache.hertzbeat.alert.notice.impl.EmailAlertNotifyHandlerImpl
required a bean of type 'org.springframework.mail.javamail.JavaMailSender'
that could not be found.
```
`EmailAlertNotifyHandlerImpl` constructor-injects `JavaMailSender`. Spring Boot only auto-configures that bean when `spring.mail.host` (etc.) is set. No mail config → no bean → application context fails → process exits.
In Docker with `restart: unless-stopped`, this becomes a **crash loop** even when the only real notify path is webhook/Discord and email is never used.
## Expected
- No `spring.mail` → HertzBeat starts normally.
- Email notify channels are unavailable (or clearly report “mail not configured”) until mail is set.
- Behavior matches the documented “mail optional” story.
## Actual
- Missing `spring.mail` → fatal startup failure.
- Workaround: add a **dummy** `spring.mail` block so `JavaMailSender` exists, even though nothing sends email.
## Environment
- Image: `apache/hertzbeat:1.8.0`
- Notify: webhook/Discord only (no email)
- Deploy: Docker Compose, custom `application.yml` mounted
## Fix
PR: (will link after open)
Smoke-tested on DietPi at SHA `03956af9a87e9a2c214e9808e28f253edaf6bd8a` with `spring.mail` fully omitted: healthy container, Restarts=0, clear email-not-configured error on test send, no JavaMailSender startup crash.
Contributor guide
Research direction
Start by locating EmailAlertNotifyHandlerImpl and examining its JavaMailSender constructor dependency, then run HertzBeat with spring.mail omitted. Done means the application starts normally without mail configuration while email notification attempts clearly report that mail is not configured; verify the webhook/Discord-only Docker Compose scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100