Skip to content

Commit 2bb59ab

Browse files
brunoborgesCopilot
andcommitted
Simplify to single monolithic Spring Boot application
Merge the separate backend (port 8080) and frontend (port 8081) modules into a single Spring Boot application running on port 8080. - Combine REST API + Thymeleaf web UI in one app under com.example.app - WeatherController calls WeatherForecastController directly (no HTTP) - Remove multi-module Maven structure, use single pom.xml - Update VS Code launch/tasks, devcontainer, and CI workflow - Update README to reflect simplified architecture Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 82e4c2d commit 2bb59ab

20 files changed

Lines changed: 1050 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "Java in Codespaces",
3+
"image": "mcr.microsoft.com/devcontainers/java:25",
4+
"features": {
5+
"ghcr.io/devcontainers/features/java:1": {
6+
"version": "25",
7+
"installMaven": "true"
8+
},
9+
"ghcr.io/devcontainers/features/github-cli:1": {
10+
"version": "2"
11+
},
12+
"ghcr.io/devcontainers/features/common-utils:2": {}
13+
},
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"vscjava.vscode-java-pack",
18+
"vmware.vscode-spring-boot",
19+
"GitHub.copilot",
20+
"GitHub.vscode-github-actions"
21+
]
22+
}
23+
},
24+
"forwardPorts": [
25+
8080
26+
],
27+
"postCreateCommand": "cd ./sample-app && mvn dependency:resolve --quiet",
28+
"hostRequirements": {
29+
"memory": "8gb",
30+
"cpus": 4
31+
},
32+
"portsAttributes": {
33+
"8080": {
34+
"label": "Weather App",
35+
"onAutoForward": "notify"
36+
}
37+
}
38+
}

.devcontainer/icon.svg

Lines changed: 10 additions & 0 deletions
Loading

.github/workflows/build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
20+
- name: Setup Java
21+
uses: actions/setup-java@v5
22+
with:
23+
distribution: 'temurin'
24+
java-version: '25'
25+
cache: 'maven'
26+
27+
- name: Build
28+
run: mvn compile -f sample-app/pom.xml

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Compiled class files
2+
*.class
3+
4+
# Log files
5+
*.log
6+
7+
# Package files
8+
*.jar
9+
*.war
10+
*.nar
11+
*.ear
12+
*.zip
13+
*.tar.gz
14+
*.rar
15+
16+
# Build directories
17+
target/
18+
19+
# IDE files
20+
.idea/
21+
*.iml
22+
*.iws
23+
*.ipr
24+
.classpath
25+
.project
26+
.settings/
27+
.factorypath
28+
29+
# VS Code
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json
35+
36+
# Maven
37+
.mvn/timing.properties
38+
.mvn/wrapper/maven-wrapper.jar
39+
40+
# OS files
41+
.DS_Store
42+
Thumbs.db
43+
44+
# Environment
45+
.env

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "SampleApp",
6+
"type": "java",
7+
"request": "launch",
8+
"mainClass": "com.example.app.Application",
9+
"projectName": "sample-app",
10+
"cwd": "${workspaceFolder}/sample-app"
11+
}
12+
]
13+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic"
3+
}

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"type": "shell",
7+
"command": "mvn",
8+
"args": [
9+
"compile",
10+
"-f",
11+
"${workspaceFolder}/sample-app/pom.xml"
12+
],
13+
"problemMatcher": []
14+
},
15+
{
16+
"label": "package",
17+
"type": "shell",
18+
"command": "mvn",
19+
"args": [
20+
"package",
21+
"-DskipTests",
22+
"-f",
23+
"${workspaceFolder}/sample-app/pom.xml"
24+
],
25+
"problemMatcher": []
26+
}
27+
]
28+
}

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# GitHub Codespaces ♥️ Java
2+
3+
Want to try out Java for web development?
4+
5+
This repo builds a Weather App with a REST API (with OpenAPI/Swagger UI) and a web frontend, all in a single Spring Boot application using Thymeleaf.
6+
7+
Everything you do here is contained within this one codespace. There is no repository on GitHub yet. If and when you're ready you can click "Publish Branch" and we'll create your repository and push up your project. If you were just exploring then and have no further need for this code then you can simply delete your codespace and it's gone forever.
8+
9+
### Run Options
10+
11+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=lightgrey&logo=github)](https://codespaces.new/github/java-codespaces)
12+
[![Open in Dev Container](https://img.shields.io/static/v1?style=for-the-badge&label=Dev+Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/github/java-codespaces)
13+
14+
You can also run this repository locally by following these instructions:
15+
1. Clone the repo to your local machine `git clone https://github.com/github/java-codespaces`
16+
1. Open repo in VS Code
17+
18+
## Getting started
19+
20+
1. **📤 One-click setup**: [Open a new Codespace](https://codespaces.new/github/java-codespaces), giving you a fully configured cloud developer environment.
21+
2. **▶️ Run all, one-click again**: Use VS Code's built-in *Run* command and open the forwarded port *8080* in your browser.
22+
23+
3. The web app will be available on port **8080**. Navigate to **/swagger-ui** for interactive API documentation.
24+
25+
4. **🔄 Iterate quickly:** Codespaces updates the server on each save, and VS Code's debugger lets you dig into the code execution.
26+
27+
5. To stop running, return to VS Code, and click Stop in the debug toolbar.
28+
29+
## Project Structure
30+
31+
```
32+
sample-app/
33+
├── pom.xml # Maven project
34+
└── src/main/
35+
├── java/com/example/app/
36+
│ ├── Application.java
37+
│ ├── WeatherForecast.java
38+
│ ├── WeatherForecastController.java
39+
│ └── WeatherController.java
40+
└── resources/
41+
├── application.properties
42+
├── templates/
43+
│ ├── index.html
44+
│ └── error.html
45+
└── static/css/site.css
46+
```
47+
48+
## Tech Stack
49+
50+
- **Java 25** with Spring Boot 3.5
51+
- **API**: Spring Web + springdoc-openapi (Swagger UI)
52+
- **Web UI**: Thymeleaf + Bootstrap 5
53+
- **Build**: Maven
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

0 commit comments

Comments
 (0)