Skip to content

sascha-frinken/grails-each-property-issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

EachProperty does not work in grails / spring

  1. Build and publish micronaut lib with an EachProperty
cd each-property
./gradlew publishToMavenLocal

TestConfiguration class:

@EachProperty("test.data")
@ToString(includeNames = true, includePackage = false)
class TestConfiguration {

    private final String name
    String prop

    TestConfiguration(@Parameter String name) {
        this.name = name
    }
}

TestService class:

@Singleton
class TestService {

    private final ApplicationContext applicationContext

    TestService(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext
    }

    Collection<TestConfiguration> getTestConfigurations() {
        applicationContext.getBeansOfType(TestConfiguration)
    }
}
  1. Run grails project
cd grails
./grailsw run
  1. Call Test Controller
curl http://localhost:8080/test

TestController class:

class TestController {
	static responseFormats = ['json']

    @Autowired
    TestService testService

    def index() {

        def configurations = testService.testConfigurations

        render([result: configurations.size()] as JSON)
    }
}

Expected:

result (configurations) should be 2 as application.yml contains:

test:
    data:
        a:
            prop: a
        b:
            prop: b

Actually:

result (configurations) is 0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published