Repository navigation
Configuration Guide
Kavindu Sahan Silva edited this page Oct 24, 2025
·
1 revision
Comprehensive guide to configuring HealthFirst Hospital Management System.
-
Location:
src/main/resources/application.properties - Purpose: Main application configuration
- Format: Java Properties
-
Security:
src/main/java/com/hospital/hospitalmanagementsystem/security/SecurityConfig.java -
Web:
src/main/java/com/hospital/hospitalmanagementsystem/config/WebConfig.java -
App:
src/main/java/com/hospital/hospitalmanagementsystem/config/AppConfig.java
# Database Connection
spring.datasource.url=jdbc:mysql://localhost:3306/hospital_management?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=your_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver# HikariCP Configuration
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=1200000# JPA Settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.jdbc.batch_size=20
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true| Value | Description | Use Case |
|---|---|---|
create |
Drops and recreates tables | Development only |
create-drop |
Creates on start, drops on stop | Testing |
update |
Updates schema | Development |
validate |
Validates schema only | Production |
none |
No action | Production (with migrations) |
# Production Database (e.g., AWS RDS)
spring.datasource.url=jdbc:mysql://hospital-db.xxxxx.us-east-1.rds.amazonaws.com:3306/hospital_management
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}# Gmail SMTP
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your-email@gmail.com
spring.mail.password=your-app-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
# Email Settings
spring.mail.default-encoding=UTF-8
spring.mail.test-connection=false# Outlook SMTP
spring.mail.host=smtp-mail.outlook.com
spring.mail.port=587
spring.mail.username=your-email@outlook.com
spring.mail.password=your-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true# SendGrid SMTP
spring.mail.host=smtp.sendgrid.net
spring.mail.port=587
spring.mail.username=apikey
spring.mail.password=YOUR_SENDGRID_API_KEY
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true# Template Settings
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html# File Upload
app.upload.dir=uploads/medicines
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
spring.servlet.multipart.file-size-threshold=2KB# File Storage Locations
app.upload.medicine-images=uploads/medicines
app.upload.bank-slips=uploads/bank-slips
app.upload.prescriptions=uploads/prescriptions
app.upload.reports=uploads/reports
# Allowed File Types
app.upload.allowed-extensions=.jpg,.jpeg,.png,.pdf,.doc,.docxuploads/
βββ medicines/ # Medicine images
βββ bank-slips/ # Payment proof documents
βββ prescriptions/ # Patient prescription files
βββ reports/ # Generated reports
# Session Settings
server.servlet.session.timeout=30m
server.servlet.session.cookie.http-only=true
server.servlet.session.cookie.secure=true
server.servlet.session.cookie.same-site=strict// In SecurityConfig.java
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(12); // Strength: 12
}# CORS Settings
spring.web.cors.allowed-origins=http://localhost:3000,https://yourdomain.com
spring.web.cors.allowed-methods=GET,POST,PUT,DELETE,OPTIONS
spring.web.cors.allowed-headers=*
spring.web.cors.allow-credentials=true# HTTPS Configuration
server.ssl.enabled=true
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=your_keystore_password
server.ssl.key-store-type=PKCS12
server.ssl.key-alias=tomcat
server.port=8443# Server Port
server.port=8080
# Context Path (optional)
server.servlet.context-path=/hospital
# Access URL: http://localhost:8080/hospital# Logging Levels
logging.level.root=INFO
logging.level.com.hospital.hospitalmanagementsystem=DEBUG
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
# Log File Configuration
logging.file.name=logs/application.log
logging.file.max-size=10MB
logging.file.max-history=30
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n# Error Pages
server.error.whitelabel.enabled=false
server.error.include-message=always
server.error.include-binding-errors=always
server.error.include-stacktrace=on_param
server.error.include-exception=true# Appointment Settings
app.appointment.slot-duration=30
app.appointment.advance-booking-days=30
app.appointment.cancellation-hours=24
app.appointment.working-hours-start=09:00
app.appointment.working-hours-end=17:00# Payment Settings
app.payment.card-processing-fee=2.5
app.payment.payment-plan-min-months=3
app.payment.payment-plan-max-months=12
app.payment.late-payment-penalty=5.0# Pharmacy Settings
app.pharmacy.low-stock-threshold=10
app.pharmacy.reorder-quantity=50
app.pharmacy.prescription-validity-days=30# application-dev.properties
spring.profiles.active=dev
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
logging.level.root=DEBUG# application-prod.properties
spring.profiles.active=prod
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate
logging.level.root=WARN
server.ssl.enabled=true# application-test.properties
spring.profiles.active=test
spring.datasource.url=jdbc:h2:mem:testdb
spring.jpa.hibernate.ddl-auto=create-dropCreate .env file in project root:
# Database
DB_HOST=localhost
DB_PORT=3306
DB_NAME=hospital_management
DB_USERNAME=root
DB_PASSWORD=your_password
# Email
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USERNAME=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
# Security
JWT_SECRET=your_secret_key_here
SESSION_TIMEOUT=30m
# File Upload
UPLOAD_DIR=uploads/
MAX_FILE_SIZE=10MBspring.datasource.url=jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hospital_management}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
spring.mail.username=${EMAIL_USERNAME}
spring.mail.password=${EMAIL_PASSWORD}# Actuator Configuration
management.endpoints.web.exposure.include=health,info,metrics,env
management.endpoint.health.show-details=when-authorized
management.metrics.enable.jvm=true
management.metrics.enable.system=truehttp://localhost:8080/actuator/health
http://localhost:8080/actuator/info
http://localhost:8080/actuator/metrics
# Performance Settings
spring.jpa.properties.hibernate.jdbc.batch_size=50
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
# Connection Pool Optimization
spring.datasource.hikari.maximum-pool-size=20
spring.datasource.hikari.minimum-idle=10
# Caching
spring.cache.type=caffeine
spring.cache.caffeine.spec=maximumSize=1000,expireAfterWrite=10m- Database connection configured and tested
- Email settings configured with valid credentials
- File upload directories created with proper permissions
- Session timeout set appropriately
- Logging configured for environment
- SSL/TLS enabled for production
- Environment variables secured
- CORS configured for allowed origins
- Actuator endpoints secured
- Performance settings optimized
Questions? Check the FAQ or open an issue