Description
Thanks for reporting an issue for Micronaut, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.
Task List
- Steps to reproduce provided
- Stacktrace (if present) provided
- Example that reproduces the problem uploaded to Github
- Full description of the issue provided (see below)
Steps to Reproduce
- clone the following repository: https://github.com/rgilles/mn-data-class-config.git
- run
mvn test
- see the test in error
Bis
- create a Kotlin
data class
annotated with@ConfigurationProperties
- Inject the dataclass in the application or a test
- you get the following error:
io.micronaut.context.exceptions.DependencyInjectionException:
Failed to inject value for parameter [name] of class: mn.dataclass.config.MyConfig
Message: No bean of type [java.lang.String] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Path Taken: MyConfigTest.config --> new MyConfig([String name])
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [java.lang.String] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Workaround:
Mix Java and Kotlin in the project and do the same thing but use Java POJO instead of Kotlin data class for the @ConfigurationProperties
then it will works.
Expected Behaviour
@ConfigurationProperties
should work with Kotlin data class as it works with Java POJO
Actual Behaviour
If you use @ConfigurationProperties
on a Kotlin data class an exception is throw at runtime
Environment Information
- Operating System: Linux 4.15.0-48-generic Add profiles to CI and publish snapshots / releases #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Micronaut Version: 1.1.0
- JDK Version:
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)