Okta in Spring Boot

🔑 What is Okta? Okta is an identity management platform that provides authentication, authorization, and user management. Instead of building your own login system, you can use Okta as your identity provider (IdP). ⚙️ Setup: Spring Boot + Okta 1. Create an Okta Developer Account Sign up at Okta Developer. Log in → go…

0 Comments

Vault in Spring Boot

Spring Boot integrates very well with HashiCorp Vault to securely manage secrets (like DB credentials, API keys, tokens) instead of hardcoding them in application.properties. Here’s a step-by-step guide with example: 🔹 1. Setup Vault Install Vault locally (or use Docker): docker run --cap-add=IPC_LOCK -d --name=dev-vault -p 8200:8200 vault:latest Start Vault in dev mode: vault…

0 Comments

CORS in Spring Boot

🔹 What is CORS? By default, a browser blocks frontend apps running at a different origin (e.g., http://localhost:3000) from calling APIs at another origin (e.g., http://localhost:8080). CORS is a mechanism that allows servers to specify which origins are allowed. 🔹 Ways to Enable CORS in Spring Boot 1. Enable CORS on a specific controller…

0 Comments

Keycloak in Spring Boot

🔐 Spring Security + Keycloak Flow Schema [Client Request] │ │ GET /admin/dashboard ▼ ┌─────────────────────────────┐ │ Spring Security Filter Chain│ │ ────────────────────────── │ │ Filters: │ │ - OAuth2LoginAuthentication │ │ - BearerTokenAuthentication │ │ - SecurityContextPersistence │ └─────────────────────────────┘ │ │ No authentication? ▼ ┌─────────────────────────────┐ │ Redirect to Keycloak Login │ │ (Authorization Endpoint)…

0 Comments

Wiremock in Spring Boot

1. Add dependencies In your pom.xml (for Maven) include: <dependencies> <!-- Spring Boot Starter Test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- WireMock for mocking HTTP services --> <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock-jre8</artifactId> <version>2.35.0</version> <scope>test</scope> </dependency> <!-- Optional: RestTemplate if using it for HTTP calls --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <dependencies> <!-- Spring Boot Starter…

0 Comments

Basic Authentification in Spring Boot

1️⃣ Project Structure spring-security-demo/ ├── lib/ # Put all Spring Boot JARs here ├── src/ │ └── main/ │ └── java/ │ └── com/example/demo/ │ ├── DemoApplication.java │ ├── SecurityConfig.java │ ├── UserController.java │ └── CustomUserDetailsService.java spring-security-demo/ ├── lib/ # Put all Spring Boot JARs here ├── src/ │ └── main/ │ └── java/…

0 Comments

Caffeine in Spring Boot

Caffeine is a high-performance, near-optimal caching library for Java that integrates very well with Spring Boot. It provides features like size-based eviction, time-based expiration, refresh, and statistics. Here’s a step-by-step guide with example: 1. Add Dependencies In Maven: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>3.1.8</version> <!-- use latest --> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId>…

0 Comments

Elasticsearch in Spring Boot

1. Setup Maven Dependencies In your pom.xml: <dependencies> <!-- Spring Boot Web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Data Elasticsearch --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> <!-- Lombok (optional, for getters/setters) --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!-- Spring Boot Test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencies> <!-- Spring Boot Web -->…

0 Comments

Hibernate in Spring Boot

🔑 Hibernate / JPA Annotations Cheat Sheet AnnotationPurpose@EntityMarks a class as a persistent entity (mapped to a table).@Table(name = "...")Customizes the table name.@IdMarks the primary key field.@GeneratedValue(strategy = ...)Specifies primary key generation strategy. Common for Postgres: GenerationType.IDENTITY or GenerationType.SEQUENCE.@ColumnCustomizes a column (name, nullable, length, unique, etc.).@ManyToOneDefines a many-to-one relationship (foreign key).@OneToManyDefines a one-to-many relationship…

0 Comments

Spring Data JPA

🚀 Common Spring Data JPA Annotations @Entity → Marks a class as a JPA entity (maps to a table). @Table → Specifies the table name in the database. @Id → Marks a field as the primary key. @GeneratedValue → Defines how the primary key is generated (IDENTITY, SEQUENCE, etc.). @Column → Customizes column mapping…

0 Comments

End of content

No more pages to load