Calorie Counter is a Spring Boot 3.3.3 demo that tracks daily food intake. It provides a simple dashboard, food entry form, and history view backed by H2 and Spring Data JPA so you can explore CRUD patterns, Thymeleaf templating, and basic nutrition calculations in a single runnable project.
- Java 17+ (Java 21 recommended). Verify with:
java -version
- Maven 3.9+ on PATH (no Maven Wrapper in repo). Verify with:
mvn -version
- Optional: VS Code with Extension Pack for Java and Spring Boot Extension Pack. Configure JDK 17+ under Java: Configure Java Runtime.
Clone the repository and switch into it:
git clone <your-fork-or-clone-url>
cd calorie-counter-
Quick start (run locally):
mvn spring-boot:run
Then open http://localhost:8080.
-
Clean build (generates executable jar):
mvn clean package
The jar appears under
target/and can be run withjava -jar target/calorie-counter-*.jar. -
Port or property overrides:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081"Additional properties can be set in
src/main/resources/application.propertiesor via-Dspring-boot.run.arguments. -
Database: Uses in-memory H2; the console is available at http://localhost:8080/h2-console with JDBC URL
jdbc:h2:mem:caldb. -
VS Code launch config (optional):
-
VS Code settings (force JDK 21):
// .vscode/settings.json { "java.configuration.runtimes": [ { "name": "JavaSE-21", "path": "C:\\Program Files\\Java\\jdk-21", "default": true } ], "java.jdt.ls.java.home": "C:\\Program Files\\Java\\jdk-21", "maven.terminal.useJavaHome": true }
- Dashboard (
/dashboard): shows today’s totals and goal progress. - Add Food (
/add): submit new food entries with name, calories, protein, carbs, and fat. - History (
/history): review previous entries and totals. - H2 Console: http://localhost:8080/h2-console (JDBC
jdbc:h2:mem:caldb).
# run
mvn spring-boot:run
# clean & rebuild
mvn clean package
# run on a different port
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081"This project uses JUnit 5 with the Spring Boot test starter. To run the full suite:
# run all tests (recommended)
mvn test
# run a specific test class
mvn -Dtest=LogServiceTest testThis repo does not ship the Maven Wrapper scripts. Use mvn instead (Maven 3.9+ on PATH).
If you want to add the wrapper locally:
mvn -N wrapper:wrapper -Dmaven=3.9.9You’re using Java 8. Switch default Java to 17+ (21 recommended).
java -versionshould show17or21.- On Windows/VS Code, set JDK 21 under Java: Configure Java Runtime.
Run on a different port:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8081"Or free the port (Windows):
netstat -ano | findstr :8080
tasklist /FI "PID eq <PID>"
taskkill /PID <PID> /FAlready fixed: controller precomputes percent; views avoid method calls.
We provide simple scripts to verify Java, Maven/Wrapper, and port status:
scripts/env-check.ps1(Windows PowerShell)scripts/env-check.sh(macOS/Linux)
Run them from repo root; they will print helpful hints.
src/main/java/edu/csu/caloriecounter/...
src/main/resources/templates/
src/main/resources/application.properties
docs/class-diagram.puml
docs/food-catalog.xlsx (food presets loaded by the app)
Include this in bug reports:
java -version
mvn -version
git rev-parse --short HEAD