Skip to content

ConfigurationPropertiesScan #50

Open

Description

@ScyAge

When I follow the tutorial available on the PKL doc https://pkl-lang.org/spring/current/usage.html, and it is specified to use either the spring @ConfigurationPropertiesScan annotation in order to detect configuration files, I cannot launch my application. I have to use the annotation @EnableConfigurationProperties({AppConfig.class,AppConfig.Server.class}) with all the necessary annotation classes, which is annoying if there are a lot of configuration classes

Here is my build.grade for the version

plugins {
    id 'java'
    id 'org.springframework.boot' version '4.0.6'
    id 'io.spring.dependency-management' version '1.1.7'
    id "org.pkl-lang" version "0.31.1"
}

group = 'univ.lille'
version = '0.0.1-SNAPSHOT'
description = 'test-spring-plk-2'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-webmvc'
    testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
    implementation "org.pkl-lang:pkl-spring:0.18.0"
}

tasks.named('test') {
    useJUnitPlatform()
}

pkl {
    javaCodeGenerators {
        configClasses {
            generateGetters.set(true)
            generateSpringBootConfig.set(true)
            sourceModules.set(files("src/main/resources/AppConfig.pkl"))
        }
    }
}

Here is the structure of my project:

Image

Thanks for the future help.

Activity

  1. Vcode2407 commented on Nov 15, 2026

    @Vcode2407

    I ran the documented sample against main (a1baaec) with Spring Boot 4.0.6, Pkl codegen 0.31.1, and Java 17. It started and bound the Pkl configuration with the default scan. I reproduced a startup error for a missing AppConfig.Server bean when the generated classes were outside the application's scan package.

    If your generated classes are in a separate package, try pointing the scan at AppConfig on your application class.

    @ConfigurationPropertiesScan(basePackageClasses = AppConfig.class)

    That let the same app start and bind the generated configuration in my test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions