0Pricing
Java Academy · Lesson

Config & Profiles

Manage configuration with application.properties and use profiles for environments.

Config & Profiles is a free Java Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Java Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Intro

Spring config uses application.properties or YAML to set values like ports and DB URLs.

Profiles

Profiles let you load different configs for dev, test, or production environments.

Code: read config

You can read config values from properties files; Spring injects them into beans.

import java.util.*;public class Main {
  public static void main(String[] args) {
    Properties props = new Properties();
    props.setProperty("server.port", "8080"); // pretend from application.properties
    System.out.println("Server will run on port: " + props.getProperty("server.port"));
  }
}

Code: profile switch

Profiles switch between configurations, e.g., H2 for dev and PostgreSQL for production.

public class Main {
  public static void main(String[] args) {
    String profile = "dev"; // pretend active profile
    if ("dev".equals(profile)) {
      System.out.println("Using H2 in-memory DB for development");
    } else if ("prod".equals(profile)) {
      System.out.println("Using PostgreSQL DB for production");
    }
  }
}

Benefits

Benefits: cleaner separation of configs, easier deployment, fewer mistakes when switching environments.

Code: conditional bean

Conditional beans let you load test doubles in test profile, and real beans in production.

public class Main {
  public static void main(String[] args) {
    String profile = "test"; // pretend active profile
    if ("test".equals(profile)) {
      System.out.println("Loading fake email sender for testing");
    } else {
      System.out.println("Loading real email sender");
    }
  }
}

Profiles check

Quick check: What is the purpose of Spring profiles?

Recap

Recap: Used application.properties, switched configs with profiles, and simulated conditional beans.

Frequently asked questions

Is the “Config & Profiles” lesson free?

Yes — the full text of “Config & Profiles” is free to read here on the web, and the Java Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Java Academy course, upgrade to CoddyKit PRO.

What will I learn in “Config & Profiles”?

Manage configuration with application.properties and use profiles for environments. You practise Java Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Java Academy?

No prior experience is required. Java Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Config & Profiles” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Java Academy lesson?

Yes. Every Java Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Testing Spring (WebTestClient/JUnit)
  2. Config & Profiles
  3. Packaging & Running
← Back to Java Academy