Migration Deep Dive für 21 · Maven Properties und Konfiguration öffnen →
⌂ ÜbersichtAlle Vergleiche
Modul 21 · 100 % Codeabdeckung

Maven Properties und Konfiguration

Vollständiger Legacy-Modern-Vergleich aller Java-Klassen, Tests, Maven-POMs und relevanten Ressourcen dieses Moduls. Jede Datei ist genau einmal einer fachlich passenden Vergleichsgruppe zugeordnet.

4Legacy-Dateien
4Modern-Dateien
69 → 70Codezeilen
9/9vollständig erfasst

Fachliche Einordnung

Legacy

Untypisierte java.util.Properties

Aufrufer lesen Strings und konvertieren Werte selbst oder über generische Getter.

Modern

Factory plus typisiertes Configuration Object

ConfigFactory definiert Prioritäten und erzeugt ein validiertes ApplicationConfig-Record.

Vergleichsfokus: Alle Dateien werden nach technischer Rolle und fachlicher Verantwortung gruppiert.
Wichtige Abgrenzung: One-to-many-Änderungen werden als Gruppe dargestellt; eine künstliche 1:1-Zuordnung wird vermieden.

Vollständige Abdeckungsmatrix

Die Ähnlichkeit ist eine technische Orientierung auf normalisiertem Quelltext. Sie ersetzt keine fachliche Bewertung.

VergleichsgruppeLegacy-DateienModern-DateienLegacy-ZeilenModern-ZeilenÄhnlichkeit
Build-Konfiguration11343497%
Konfigurationsquelle und Mapping2222224%
Konfigurationstest11131436%

Gemeinsame Modulstruktur

Das Pair-POM bindet die Legacy- und Modern-Submodule zusammen und gehört deshalb ebenfalls zur vollständigen Codeabdeckung.

Gemeinsam · 19 Zeilenpom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.aydin.academy</groupId>
        <artifactId>java-modernization-deep-dive</artifactId>
        <version>1.0.0</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <artifactId>21mavenpropertiesconfig-pair</artifactId>
    <packaging>pom</packaging>
    <name>Maven Properties und Konfiguration: Legacy und Modern</name>
    <modules>
        <module>legacy</module>
        <module>modern</module>
    </modules>
</project>

Alle semantischen Codevergleiche

01Build-KonfigurationDirektvergleich · Legacy 34 / Modern 34 Zeilen · Ähnlichkeit 97%

Maven-Properties und Compiler-/Testsetup werden verglichen.

Legacy-DateienModern-DateienEinordnung
pom.xmlpom.xmlDirektvergleich
Semantische Ähnlichkeit: 97%

Legacy

Legacy · 34 Zeilenlegacy/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <parent>
                <groupId>at.aydin.academy</groupId>
                <artifactId>21mavenpropertiesconfig-pair</artifactId>
                <version>1.0.0</version>
                <relativePath>../pom.xml</relativePath>
            </parent>
            <artifactId>config-properties-legacy</artifactId>
            <packaging>jar</packaging>
            <name>Properties Config Legacy</name>

            <dependencies>

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <scope>test</scope>
</dependency>

            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>

                </plugins>
            </build>
        </project>

Modern

Modern · 34 Zeilenmodern/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <parent>
                <groupId>at.aydin.academy</groupId>
                <artifactId>21mavenpropertiesconfig-pair</artifactId>
                <version>1.0.0</version>
                <relativePath>../pom.xml</relativePath>
            </parent>
            <artifactId>typed-config-modern</artifactId>
            <packaging>jar</packaging>
            <name>Typed Config Modern</name>

            <dependencies>

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <scope>test</scope>
</dependency>

            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                    </plugin>

                </plugins>
            </build>
        </project>
02Konfigurationsquelle und MappingDirektvergleich · Legacy 22 / Modern 22 Zeilen · Ähnlichkeit 4%

Direktes Properties-Lesen wird in typisiertes Mapping und Factory getrennt.

Legacy-DateienModern-DateienEinordnung
application.properties
LegacyPropertiesConfig.java
ApplicationConfig.java
ConfigFactory.java
Direktvergleich
Semantische Ähnlichkeit: 4%

Legacy

package at.aydin.lab.config.legacy;

// Design Pattern: Configuration Object – bündelt untypisierte Properties in einem Zugriffspunkt.
import java.io.*;
import java.util.*;

public final class LegacyPropertiesConfig {
    private final Properties properties = new Properties();
    public LegacyPropertiesConfig(InputStream in) throws IOException {
        properties.load(in);
    }

    public String get(String key) {
        return properties.getProperty(key);
    }

    public int getInt(String key) {
        return Integer.parseInt(get(key));
    }
}

Modern

package at.aydin.lab.config.modern;

// Design Pattern: Configuration Object
// Zweck: Zusammengehörige Einstellungen werden typisiert und validiert gebündelt.
public record ApplicationConfig(int serverPort, boolean featureEnabled) {
    public ApplicationConfig {
        if (serverPort < 1 || serverPort > 65535) throw new IllegalArgumentException("serverPort");
    }
}
package at.aydin.lab.config.modern;

import java.util.*;

// Design Pattern: Factory
// Zweck: Zentralisiert Priorität, Parsing und Validierung verschiedener Konfigurationsquellen.
public final class ConfigFactory {
    public ApplicationConfig from(Properties p, Map<String, String> env) {
        int port = Integer.parseInt(env.getOrDefault("APP_PORT", p.getProperty("server.port", "8080")));
        boolean enabled = Boolean.parseBoolean(env.getOrDefault("FEATURE_ENABLED", p.getProperty("feature.enabled", "false")));
        return new ApplicationConfig(port, enabled);
    }
}
03KonfigurationstestDirektvergleich · Legacy 13 / Modern 14 Zeilen · Ähnlichkeit 36%

Tests prüfen dieselbe Konfigurationsabsicht mit unterschiedlicher Struktur.

Legacy-DateienModern-DateienEinordnung
LegacyPropertiesConfigTest.javaConfigFactoryTest.javaDirektvergleich
Semantische Ähnlichkeit: 36%

Legacy

package at.aydin.lab.config.legacy;

import org.junit.jupiter.api.Test;
import java.io.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

class LegacyPropertiesConfigTest {
    @Test
    void readsStringKeys() throws Exception {
        var in = getClass().getResourceAsStream("/application.properties");
        assertEquals(8080, new LegacyPropertiesConfig(in).getInt("server.port"));
    }
}

Modern

package at.aydin.lab.config.modern;

import org.junit.jupiter.api.Test;
import java.util.*;
import static org.junit.jupiter.api.Assertions.*;

class ConfigFactoryTest {
    @Test
    void environmentOverridesProperties() {
        Properties p = new Properties();
        p.setProperty("server.port", "8080");
        assertEquals(9090, new ConfigFactory().from(p, Map.of("APP_PORT", "9090")).serverPort());
    }
}
⌂ Cockpit