A Spring Boot web application that displays real-time weather information for any city using the OpenWeatherMap API.
- Search weather by city name
- Display current temperature (Celsius)
- Show weather description (clear sky, cloudy, rainy, etc.)
- Display humidity percentage
- Show wind speed
- Display weather icons
- Show country code
- Java 17 - Programming language
- Spring Boot 3.x - Backend framework
- Spring MVC - Web framework
- Thymeleaf - Template engine for HTML
- RestTemplate - HTTP client for API calls
- OpenWeatherMap API - Weather data provider
- Maven - Build and dependency management tool
Before running this application, make sure you have:
- Java JDK 11 or higher installed
- Maven 3.6+ installed
- An OpenWeatherMap API key (free tier available)
- Internet connection
git clone https://github.com/adelekeemmanuel/Weather-App.git
cd Weather-App- Visit OpenWeatherMap
- Click Sign Up and create a free account
- Verify your email address
- Go to API Keys section in your dashboard
- Copy your API key (it looks like:
abc123def456ghi789)
Open src/main/resources/application.properties and replace the placeholder:
Change this:
api.key=YOUR_API_KEY_HERETo this (with your actual key):
api.key=abc123def456ghi789💡 Important: Never share this file or push it to GitHub with your real API key!
mvn spring-boot:run- Locate
WeatherAppApplication.java(main class) - Right-click on the file
- Select Run 'WeatherAppApplication'
mvn clean package
java -jar target/Weather-App-0.0.1-SNAPSHOT.jarOpen your web browser and go to:
http://localhost:8080/abc
- 🚀 Launch the application
- 🌐 Open
http://localhost:8080/abcin your browser - 📝 Enter a city name (e.g., "London", "New York", "Tokyo")
- 🖱️ Click "Get Weather" or press Enter
- 📊 View the current weather information displayed
Weather-App/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/weather/Weather_App/
│ │ │ ├── WeatherAppApplication.java # Main application class
│ │ │ ├── controller/
│ │ │ │ └── WeatherController.java # Handles web requests
│ │ │ └── model/
│ │ │ └── WeatherResponse.java # API response model
│ │ └── resources/
│ │ ├── application.properties # Configuration (NOT in Git)
│ │ ├── static/
│ │ │ ├── css/ # CSS stylesheets
│ │ │ │ ├── index.css
│ │ │ │ └── weather.css
│ │ │ └── images/ # Image assets
│ │ └── templates/
│ │ ├── index.html # Search page
│ │ └── weather.html # Results page
│ └── test/ # Test files
├── target/ # Compiled files (ignored)
├── .gitignore # Git ignore rules
├── pom.xml # Maven configuration
└── README.md # This file
The application uses the following configuration (in application.properties):
# API Configuration
api.key=YOUR_API_KEY_HERE
# Server Configuration
server.port=8080
# Application Name
spring.application.name=Weather-AppChange the port:
server.port=9090 # Now runs on http://localhost:9090Use environment variable for API key:
api.key=${WEATHER_API_KEY:default_key}| Method | Endpoint | Description |
|---|---|---|
| GET | /abc |
Home page with search form |
| GET | /weather?city={cityName} |
Get weather for specified city |
Example:
http://localhost:8080/weather?city=London
- Keep your API key in
application.properties(ignored by Git) - Use environment variables for production deployment
- Monitor your API usage on OpenWeatherMap dashboard
- Set up rate limiting if exposing the API publicly
- Never commit
application.propertieswith real API keys - Don't share your API key in screenshots or messages
- Don't hardcode API keys in Java files
- Don't expose the API key in frontend JavaScript
OpenWeatherMap Free Tier:
- ⏱️ 60 calls per minute
- 📅 1,000,000 calls per month
- 🌍 Current weather data only
- ⏰ Data updates every 10 minutes
If you exceed these limits, you'll get HTTP 429 (Too Many Requests) error.
Solutions:
- ✓ Check spelling of the city name
- ✓ Use English names for international cities
- ✓ Try adding country code: "Paris,FR" or "London,GB"
Solutions:
- ✓ Verify API key is correct in
application.properties - ✓ Check if port 8080 is already in use
- ✓ Ensure Java and Maven are properly installed
- ✓ Run
mvn clean installto rebuild
Solutions:
- ✓ Verify your API key is active
- ✓ Wait 10-15 minutes after creating new API key (activation time)
- ✓ Check for extra spaces in the API key
Solutions:
- ✓ Check your internet connection
- ✓ Verify OpenWeatherMap API is not down
- ✓ Check firewall settings
Solutions:
- ✓ Check your internet speed
- ✓ OpenWeatherMap free tier may have delays
- ✓ Consider caching weather data
Run tests with:
mvn testCreate an executable JAR:
mvn clean packageThe JAR file will be created in target/Weather-App-0.0.1-SNAPSHOT.jar
Run the JAR:
java -jar target/Weather-App-0.0.1-SNAPSHOT.jar- Heroku: Easy deployment with free tier
- AWS Elastic Beanstalk: Scalable cloud deployment
- Docker: Containerized deployment
- Traditional Server: Deploy JAR to any server with Java
Contributions are welcome! Here's how:
- 🍴 Fork the repository
- 🌿 Create a feature branch:
git checkout -b feature/AmazingFeature - 💾 Commit your changes:
git commit -m 'Add some AmazingFeature' - 📤 Push to the branch:
git push origin feature/AmazingFeature - 🔃 Open a Pull Request
- Add 5-day weather forecast
- Implement weather alerts
- Add temperature unit toggle (Celsius/Fahrenheit)
- Save favorite cities
- Add weather maps
- Implement geolocation for automatic city detection
- Add dark mode
- Create mobile-responsive design
- Add weather history charts
This project is open source and available under the MIT License.
Your Name
- GitHub: https://github.com/adelekeemmanuel
- Email: adelekeemmanuel29@gmail.com
- OpenWeatherMap - For providing the weather API
- Spring Boot - For the amazing framework
- Thymeleaf - For the template engine
- Maven - For build management
If you have any questions or run into issues:
- Check the Troubleshooting section
- Open an issue on GitHub
- Contact me via email
Search for any city to get weather information
Detailed weather information with icons
Made with ❤️ and ☕ by Adeleke Emmanuel
⭐ Star this repo if you found it helpful!