- Motivation: Show how to build a Spring Boot API service using Maven and deploy it to Heroku, comparing with using Gradle.
Project Details:
- API Specification: In YAML format (
openapi.yaml
), defining endpoints for getting all quotes, a random quote, and a quote by ID. - Build Tools: Using Maven instead of Gradle, with
spring init
command to create thequotes-maven
project and specifying dependencies likespring-boot-starter-web
,springdoc-openapi-starter-webmvc-ui
, etc. inpom.xml
. - Business Logic: Copied from the Gradle-based service and placed in appropriate packages.
- Deployment: Created
system.properties
andProcfile
, authenticated with Heroku CLI, created a new app, and pushed code withgit push heroku master
.
- API Specification: In YAML format (
- Testing: Sent
curl
requests to test the API endpoints and browse Swagger Docs. - Comparison: Gradle is good for fast builds and flexibility, while Maven is better for standardized builds and stable support. A 2024 study showed worldwide preference for Maven over Gradle.
- Conclusion: Demonstrated how Spring Boot, Maven, and Heroku enabled quick realization of an idea by focusing on functionality and leveraging frameworks and services, with source code available on GitLab.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。