A simple Hello World project to introduce Java development with Maven, JUnit 5 unit testing, and GitHub Actions CI.
This project is a starting point for students to get familiar with:
- Structuring a Java project using Maven
- Writing and running unit tests with JUnit 5
- Automating tests with GitHub Actions on every push
- Java 21 JDK
- Apache Maven 3.x
- A terminal / command prompt
Verify your setup:
java -version # should show 21.x
mvn -version # should show 3.x-
Clone the repository
git clone https://github.com/w0242502/hello-maven.git cd HelloMaven -
Compile and run
mvn compile exec:java -Dexec.mainClass="Main"Expected output:
Hello, Maven! -
Run the unit tests
mvn testA passing run looks like:
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS
HelloMaven/
├── src/
│ ├── main/java/
│ │ └── Main.java # Application source code
│ └── test/java/
│ └── MainTest.java # JUnit 5 unit tests
├── .github/workflows/
│ └── ci.yml # GitHub Actions workflow
└── pom.xml # Maven project configuration
Every push and pull request automatically runs mvn test in the cloud. Check the Actions tab in GitHub to see results.